コード例 #1
0
ファイル: frmCompany.cs プロジェクト: windygu/SGWMS
        public bool OpenMainDataSet(string sCon)
        {
            bool   bIsOK = false;
            string strX  = "";

            grdList.AutoGenerateColumns = false;
            grdList.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            DBDataSet.Clear();
            DBCommInfo.DBSQLCommandInfo cmdInfo = new DBSQLCommandInfo(); //执行命令的对象
            cmdInfo.SqlText = "select * from " + strTbNameMain + sCon;    //SQL语句  或 存储过程名 若有参数,另外在参数集里增加
            //if (UserInformation.UType != UserType.utSupervisor)
            //{
            //    cmdInfo.SqlText = cmdInfo.SqlText + " where "+strKeyFld+"='"+ UserInformation.UnitId +"'"; //仅显示当前用户的单位
            //}
            cmdInfo.SqlType       = SqlCommandType.sctSql;                  //SQL命令类型  SqlCommandType.sctSql  SQL 语句 SqlCommandType.sctProcedure 表存储过程
            cmdInfo.PageIndex     = 0;                                      //需要分页时的页号
            cmdInfo.PageSize      = 0;                                      //需要分页时的每页记录条数
            cmdInfo.FromSysType   = "dotnet";                               //采用处理结果数据的方式:php 表按照<tr><td></td></tr> xml 否则 直接采用ado 的记录集方式
            cmdInfo.DataTableName = strTbNameMain;                          //指定结果数据记录集表名
            SunEast.SeDBClient sdcX = new SeDBClient();                     //获取服务器数据的类型对象
            //sdcX.DBSTServer = DBSocketServerType.dbsstNormal;  //自动根据配置文件读
            string sErr = "";

            //DataSet dsX = null;
            //DataTable tbX= null ;
            DBDataSet = sdcX.GetDataSet(cmdInfo, out sErr);               //通过获取服务器数据对象的GetDataSet方法获取数据
            bIsOK     = DBDataSet != null;
            //if (bIsOK)
            //{
            //    DBDataSet.Clear();
            //    tbX  = new DataTable(strTbNameMain);
            //    tbX = dsX.Tables["data"].Copy();
            //    DBDataSet.Tables.Add(tbX);
            //}
            if (!bIsOK)
            {
                MessageBox.Show(sErr);
            }
            else
            {
                try
                {
                    //DBDataSet.Tables["data"].TableName = strTbNameMain;
                    DataSetUnBind(pnlEdit);
                    this.bdsMain.DataSource = DBDataSet.Tables[strTbNameMain];
                    if (bdsMain != null && bdsMain.Count > 0)
                    {
                        BindDataSetToCtrls();
                    }
                    bIsOK   = true;
                    optMain = OperateType.optNone;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    bIsOK = false;
                }
            }
            return(bIsOK);
        }
コード例 #2
0
        public bool OpenMainDataSet(string sCon)
        {
            bool   bIsOK = false;
            string strX  = "";
            string sSql  = "";
            string sErr  = "";

            bDSIsOpenForMain            = false;
            grdList.AutoGenerateColumns = false;
            grdList.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            DBDataSet.Clear();
            sSql      = "select * from " + strTbNameMain + sCon;        //SQL语句  或 存储过程名 若有参数,另外在参数集里增加
            DBDataSet = SunEast.App.PubDBCommFuns.GetDataBySql(sSql, strTbNameMain, 0, 0, out sErr);
            bIsOK     = DBDataSet != null;
            if (bIsOK)
            {
                bIsOK = DBDataSet.Tables[0].Rows[0][0].ToString().Trim() == "0";
            }
            //if (bIsOK)
            //{
            //    DBDataSet.Clear();
            //    tbX  = new DataTable(strTbNameMain);
            //    tbX = dsX.Tables["data"].Copy();
            //    DBDataSet.Tables.Add(tbX);
            //}
            if (!bIsOK)
            {
                MessageBox.Show(sErr);
            }
            else
            {
                try
                {
                    bDSIsOpenForMain        = true;
                    this.bdsMain.DataSource = DBDataSet.Tables[strTbNameMain];
                    BindDataSetToCtrls();
                    ClearUIValues(pnlEdit);
                    if (bdsMain.Count > 0)
                    {
                        DataRowViewToUI((DataRowView)bdsMain.Current, pnlEdit);
                    }
                    bIsOK              = true;
                    optMain            = OperateType.optNone;
                    btn_SetPwd.Visible = false;
                    btn_SetPwd.Enabled = false;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    bIsOK = false;
                }
            }
            return(bIsOK);
        }
コード例 #3
0
ファイル: FrmStockMAjust.cs プロジェクト: windygu/SGWMS
        /*
         #region 私有变量
         * string strTbNameMain = "TWC_WareHouse";
         * string strKeyFld = "cWHId";
         * bool bDSIsOpenForMain = false;
         * //主表操作
         * OperateType optMain = OperateType.optNone;
         * //记录当前数据列表的 条件
         * StringBuilder sbConndition = new StringBuilder("");
         #endregion
         */
        //public

        private bool BandDataSet(string SqlStrConditon, DataGridView FDataGridView)
        {
            bool Result = true;

            try
            {
                string SqlStr = "";
                string ErrStr = "";
                bDSIsOpenForMain = false;
                FDataGridView.AutoGenerateColumns = false;
                FDataGridView.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
                DBDataSet.Clear();
                SqlStr         = "SELECT * FROM  " + strTbNameMain + " " + SqlStrConditon;
                Cursor.Current = Cursors.WaitCursor;
                DBDataSet      = PubDBCommFuns.GetDataBySql(AppInformation.SvrSocket, false, SqlStr, strTbNameMain, 0, 0, "dDate,dCreateDate,dCheckDate", out ErrStr);

                Result = DBDataSet != null;
                bindingSource_Main.DataSource = DBDataSet.Tables[strTbNameMain];;
                FDataGridView.DataSource      = bindingSource_Main;
                Cursor.Current = Cursors.Default;
                string sId = "";
                if (bindingSource_Main.Count > 0)
                {
                    DataRowView drv = (DataRowView)bindingSource_Main.Current;
                    sId = drv[strKeyFld].ToString().Trim();
                    try
                    {
                        bDSIsOpenForMain = true;
                        DataRowViewToUI(drv, panel_Edit);
                        OptMain = OperateType.optNone;
                    }
                    catch (Exception e)
                    {
                        bDSIsOpenForMain = false;
                        MessageBox.Show(e.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Result = false;
                    }
                }
                BandDataSetDetail(" where cBNo='" + sId.Trim() + "'", dataGridView_Detail);
            }
            catch (Exception ei)
            {
                MessageBox.Show(ei.Message);
            }
            return(Result);
        }
コード例 #4
0
        public bool OpenMainDataSet()
        {
            //if (UserInformation.UType != UserType.utSupervisor)
            //{
            //    strConnFix = " and cCmptId='" + UserInformation.UnitId + "'";
            //}
            bool   bIsOK = false;
            string strX  = "";
            string sErr  = "";

            grdList.AutoGenerateColumns = false;
            grdList.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            DBDataSet.Clear();
            string sSql = "select * from " + strTbNameMain + " where 1=1 and cCSId='" + _CSId.Trim() + "'";

            DBDataSet = DBFuns.GetDataBySql(AppInformation.SvrSocket, false, sSql, strTbNameMain, 0, 0, "", out sErr);
            #region
            //DBCommInfo.DBSQLCommandInfo cmdInfo = new DBSQLCommandInfo();//执行命令的对象
            ////cmdInfo.SqlText = "select * from " + strTbNameMain + " where 1=1 " + sCondition + strConnFix;             //SQL语句  或 存储过程名 若有参数,另外在参数集里增加
            //cmdInfo.SqlText = "select * from " + strTbNameMain + " where 1=1 and cCSId='"+ _CSId.Trim() +"'";             //SQL语句  或 存储过程名 若有参数,另外在参数集里增加

            ////if (UserInformation.UType != UserType.utSupervisor)
            ////{
            ////    cmdInfo.SqlText = cmdInfo.SqlText + " where "+strKeyFld+"='"+ UserInformation.UnitId +"'"; //仅显示当前用户的单位
            ////}
            //cmdInfo.SqlType = SqlCommandType.sctSql;                        //SQL命令类型  SqlCommandType.sctSql  SQL 语句 SqlCommandType.sctProcedure 表存储过程
            //cmdInfo.PageIndex = 0;                                          //需要分页时的页号
            //cmdInfo.PageSize = 0;                                           //需要分页时的每页记录条数
            //cmdInfo.FromSysType = "dotnet";                                 //采用处理结果数据的方式:php 表按照<tr><td></td></tr> xml 否则 直接采用ado 的记录集方式
            //cmdInfo.DataTableName = strTbNameMain;                          //指定结果数据记录集表名
            //SunEast.SeDBClient sdcX = new SeDBClient();                     //获取服务器数据的类型对象
            ////sdcX.DBSTServer = DBSocketServerType.dbsstNormal;  //自动根据配置文件读

            ////DataSet dsX = null;
            ////DataTable tbX= null ;
            //DBDataSet = sdcX.GetDataSet(cmdInfo, out sErr);               //通过获取服务器数据对象的GetDataSet方法获取数据
            #endregion

            bIsOK = DBDataSet != null;
            //if (bIsOK)
            //{
            //    DBDataSet.Clear();
            //    tbX  = new DataTable(strTbNameMain);
            //    tbX = dsX.Tables["data"].Copy();
            //    DBDataSet.Tables.Add(tbX);
            //}
            if (!bIsOK)
            {
                MessageBox.Show(sErr);
            }
            else
            {
                try
                {
                    ClearUIValues(pnlEdit);
                    bIsMainOpened           = false;
                    this.bdsMain.DataSource = DBDataSet.Tables[strTbNameMain];
                    bIsMainOpened           = true;
                    BindDataSetToCtrls();
                    grdList.DataSource = bdsMain;
                    bIsOK   = true;
                    optMain = OperateType.optNone;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    bIsOK = false;
                }
            }
            return(bIsOK);
        }
コード例 #5
0
 public virtual int Fill(DBDataSet.ProductosDataTable dataTable) {
     this.Adapter.SelectCommand = this.CommandCollection[0];
     if ((this.ClearBeforeFill == true)) {
         dataTable.Clear();
     }
     int returnValue = this.Adapter.Fill(dataTable);
     return returnValue;
 }