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


C# DataAccess.Open方法代码示例

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


在下文中一共展示了DataAccess.Open方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例3: 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


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