当前位置: 首页>>代码示例>>C#>>正文


C# DataAccess.Close方法代码示例

本文整理汇总了C#中DataAccess.Close方法的典型用法代码示例。如果您正苦于以下问题:C# DataAccess.Close方法的具体用法?C# DataAccess.Close怎么用?C# DataAccess.Close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataAccess的用法示例。


在下文中一共展示了DataAccess.Close方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: drpDB2_DropDown

        private void drpDB2_DropDown(object sender, EventArgs e)
        {
            string strConn = DataAccess.getNewSqlConnectionString(this.txtServer2.Text, txtUser2.Text, txtPwd2.Text, "master", "PlanServer", "");
            DataAccess xudb = new DataAccess(strConn, DataAccess.DbProviderFactoryTypeEnum.SqlClient);

            try
            {
                xudb.Open();
                DataTable dtb = xudb.getDataTable("select name from master..sysdatabases order by name");
                drpDB2.Items.Clear();
                for (int i = 0; i < dtb.Rows.Count; i++)
                {
                    drpDB2.Items.Add(dtb.Rows[i]["name"].ToString());

                }
                xudb.Close();

            }
            catch (Exception ex)
            {

                MessageBox.Show(ex.Message);
            }
        }
开发者ID:ddxuqinming,项目名称:PlanServer,代码行数:24,代码来源:frmConfig.cs

示例2: UnLockStock

        private void UnLockStock()
        {
            string  strConn = DataAccess.getNewSqlConnectionString(this.PTDBCfg.Server, this.PTDBCfg.User, this.PTDBCfg.Pwd, this.PTDBCfg.Db, "PlanServer", "");
            DataAccess ptdb = new DataAccess(strConn, DataAccess.DbProviderFactoryTypeEnum.SqlClient);

            strConn = DataAccess.getNewSqlConnectionString(this.K3DBCfg.Server, this.K3DBCfg.User, this.K3DBCfg.Pwd, this.K3DBCfg.Db, "PlanServer", "");
            DataAccess k3db = new DataAccess(strConn, DataAccess.DbProviderFactoryTypeEnum.SqlClient);
            try
            {

                ptdb.Open();
                k3db.Open();

                //从信息平台取锁库记录
                DataTable dtbLock = ptdb.getDataTable("select * from uSaleLockStock where FType=2 and  DateDiff( d, FLockDate,getdate())<=90");
                var count = 0;
                string sql;
                object FAuxStockQty;//已领数量
                foreach (DataRow drw in dtbLock.Rows)
                {
                    sql = @"  select FAuxStockQty
                  from PPBOM  t1 INNER JOIN   PPBOMEntry t2 ON t1.FInterID = t2.FInterID
                  where t1.FInterID={0}   and t1.FCheckerID<>0 and t2.FEntryID={1} and t1.FBillNo='{2}'";
                    FAuxStockQty = k3db.ExecuteScalarBatch(String.Format(sql, drw["FInterID"], drw["FEntryID"], drw["FBillNo"]));

                    if (FAuxStockQty == null) //如果K3不存在(如删除、取消审核了),则删除
                    {
                        ptdb.ExeSqlBatch("delete from  uSaleLockStock where FType=2 and FAutoID=" + drw["FAutoID"]);
                    }
                    else //更新解锁数量
                    {
                        if (Conversion.Val(FAuxStockQty.ToString())>=Conversion.Val ( drw["FLockStockQty"].ToString ())) //已领数量大于锁库数量
                            ptdb.ExeSqlBatch("update    uSaleLockStock set FLockStock=2,FUnLockStockQty=" + Conversion.Val(FAuxStockQty.ToString()) + " ,FUnLockDate=getdate() where FType=2 and FAutoID=" + drw["FAutoID"]);
                        else
                            ptdb.ExeSqlBatch("update    uSaleLockStock set FUnLockStockQty=" + Conversion.Val(FAuxStockQty.ToString()) + "   where FType=2 and FAutoID=" + drw["FAutoID"]);

                    }

                    //每100行暂停下
                    count += 1;
                    if (count % 100 == 0)
                        System.Threading.Thread.Sleep(200);

                }//foreach

            }
            catch (Exception)
            {

                throw;
            }
            finally
            {

                ptdb.Close();
                k3db.Close();
            }
        }
开发者ID:ddxuqinming,项目名称:PlanServer,代码行数:58,代码来源:Plan_K3Lock.cs

示例3: LockStock

        private void LockStock()
        {
            string strConn = DataAccess.getNewSqlConnectionString(this.K3DBCfg.Server, this.K3DBCfg.User, this.K3DBCfg.Pwd, this.K3DBCfg.Db, "PlanServer", "");
            DataAccess k3db = new DataAccess(strConn, DataAccess.DbProviderFactoryTypeEnum.SqlClient);
            strConn = DataAccess.getNewSqlConnectionString(this.PTDBCfg.Server, this.PTDBCfg.User, this.PTDBCfg.Pwd, this.PTDBCfg.Db, "PlanServer", "");
            DataAccess ptdb = new DataAccess(strConn, DataAccess.DbProviderFactoryTypeEnum.SqlClient);
            try
            {

                k3db.Open();
                //1从投料单查询记录
                string sql = @"  select    t1.FInterID,t1.FBillNo  , t1.FDate ,
                 t2.FentryID, t2.FItemID,t3.FNumber  ,t3.FName  ,t3.FModel  ,t4.FName as FUnit,t2.FBatchNo  ,
                  t2.FAuxQtyMust as 计划投料数量,  getdate() as FLockDate
                  from PPBOM  t1 INNER JOIN   PPBOMEntry t2 ON t1.FInterID = t2.FInterID
                  left join t_ICItem t3 ON   t2.FItemID = t3.FItemID and t3.FItemID <>0
                  LEFT  JOIN t_MeasureUnit AS T4 ON T2.FUnitID = T4.FItemID  and T4.FItemID <>0
                  where  DateDiff( d,t1.FDate,getdate())<=60 and  t3.FBatchManager=0 --未启用批次
                  and t1.FCheckerID<>0
                   and exists(select 1 from  ICMO a join vw_ICMOStatus b on  a.FInterID = b.FInterID  --执行状态
                  where t1.FICMOInterID=a.FInterID and  b.FMoStatusName<>'完全入库'  and  b.FMoStatusName<>'结案')  ";
                DataTable dtbPPBOM = k3db.getDataTable(sql);
                k3db.Close();

                //2与信息平台比较

                ptdb.Open();
                sun.DataProvider.CommandBuilder cb = new sun.DataProvider.CommandBuilder("uSaleLockStock");
                cb.XuDb = ptdb;
                var count = 0;
                foreach (DataRow drw in dtbPPBOM.Rows)
                {
                    if (!ptdb.isExist("select 1 from uSaleLockStock where FType=2 and FInterID=" + drw["FInterID"] + " and FEntryID=" + drw["FEntryID"] + " and FBillNo='" + drw["FBillNo"] + "'"))
                    {
                        //插入
                        sun.Common.KeyValueList kv = new sun.Common.KeyValueList();
                        kv.Add("FType", 2);
                        //kv.Add("FSourceMainID", FSourceMainID);
                        //kv.Add("FSourceRequestID", FSourceRequestID);
                        //kv.Add("FSourceDetailID", _with1.Item("FAutoID"));
                        //kv.Add("FConnID", FConnID);
                        kv.Add("FInterID", drw["FInterID"]);
                        kv.Add("FBillNo", drw["FBillNo"]);
                        kv.Add("FDate", drw["FDate"]);
                        //

                        kv.Add("FEntryID", drw["FEntryID"]);
                        kv.Add("FItemID", drw["FItemID"]);
                        kv.Add("FNumber", drw["FNumber"]);
                        kv.Add("FName", drw["FName"]);
                        kv.Add("FModel", drw["FModel"]);
                        kv.Add("FUnit", drw["FUnit"]);
                        kv.Add("FBatchNo", drw["FBatchNo"]);
                        kv.Add("FLockStockQty", drw["计划投料数量"]);
                        kv.Add("FLockStock", 1); //'1-40287锁库,2-40288未锁库

                        kv.Add("FLockUser", "timer");
                        kv.Add("FLockDate", DateTime.Now);
                        System.Data.Common.DbCommand cmd = cb.CreateInsertCommand(kv, null, false);
                        ptdb.ExeSql(cmd);
                    }

                    //每100行暂停下
                    count += 1;
                    if (count % 100 == 0)
                        System.Threading.Thread.Sleep(200);

                }//foreach

            }
            catch (Exception)
            {

                throw;
            }
            finally {
                ptdb.Close();
                k3db.Close();
            }
        }
开发者ID:ddxuqinming,项目名称:PlanServer,代码行数:80,代码来源:Plan_K3Lock.cs

示例4: Save

        /// <summary>
        /// (Overrided) Saves changes to the List
        /// </summary>
        /// <param name="Da">
        /// Optional, an open Data_Access Objects that is reused from the calling method
        /// </param>
        /// <returns></returns>
        public override bool Save(DataAccess.Interface_DataAccess Da = null)
        {
            bool IsSave = false;
            bool IsDa = false;

            if (Da == null)
            {
                Da = this.mDa;
                Da.Connect();
                Da.BeginTransaction();
                IsDa = true;
            }

            try
            {
                DataRow[] ArrDr = this.mDt_List.Select("", "", DataViewRowState.CurrentRows);
                foreach (DataRow Dr in ArrDr)
                {
                    if (Dr.RowState == DataRowState.Added || Dr.RowState == DataRowState.Modified)
                    { Da.SaveDataRow(Dr, this.mHeader_TableName); }
                }

                ArrDr = this.mDt_List.Select("", "", DataViewRowState.Deleted);
                foreach (DataRow Dr in ArrDr)
                {
                    DataRow Nr = Dr.Table.NewRow();
                    foreach (DataColumn Dc in Dr.Table.Columns)
                    { Nr[Dc.ColumnName] = Dr[Dc.ColumnName, DataRowVersion.Original]; }

                    Da.SaveDataRow(Nr, this.mHeader_TableName, "", true);
                }

                if (IsDa)
                { Da.CommitTransaction(); }
                IsSave = true;
            }
            catch (Exception Ex)
            {
                if (IsDa)
                { Da.RollbackTransaction(); }
                throw Ex;
            }
            finally
            {
                if (IsDa)
                { Da.Close(); }
            }

            return IsSave;
        }
开发者ID:trickerss,项目名称:DataObjects_Framework,代码行数:57,代码来源:ClsBase_List.cs


注:本文中的DataAccess.Close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。