Exemplo n.º 1
0
        private void LoadBaseItem()
        {
            DataTable table;
            string    sErr = "";
            string    sSql = "select cTypeId,cTypeName from TPC_MaterialType where cTypeMode = 0 ";
            DataSet   set  = null;

            set = DBFuns.GetDataBySql(base.AppInformation.SvrSocket, false, sSql, "MatType", 0, 0, "", out sErr);
            if ((sErr.Trim() != "0") && (sErr.Trim() != ""))
            {
                MessageBox.Show(sErr);
            }
            if (set != null)
            {
                table = set.Tables["MatType"].Copy();
                this.cmb_cTypeId1.DisplayMember = "cTypeName";
                this.cmb_cTypeId1.ValueMember   = "cTypeId";
                this.cmb_cTypeId1.DataSource    = table;
            }
            set.Clear();
            sSql = "select cTypeId,cTypeName from TPC_MaterialType where cTypeMode = 1 ";
            set  = DBFuns.GetDataBySql(base.AppInformation.SvrSocket, false, sSql, "ACNTType", 0, 0, "", out sErr);
            if ((sErr.Trim() != "0") && (sErr.Trim() != ""))
            {
                MessageBox.Show(sErr);
            }
            if (set != null)
            {
                table = set.Tables["ACNTType"].Copy();
                this.cmb_cTypeId2.DisplayMember = "cTypeName";
                this.cmb_cTypeId2.ValueMember   = "cTypeId";
                this.cmb_cTypeId2.DataSource    = table;
            }
            set.Clear();
        }
Exemplo n.º 2
0
        private bool BandDataSet(string SqlStrConditon, DataGridView FDataGridView)
        {
            bool   flag = true;
            string sSql = "";
            string sErr = "";

            this.bDSIsOpenForMain             = false;
            FDataGridView.AutoGenerateColumns = false;
            FDataGridView.SelectionMode       = DataGridViewSelectionMode.FullRowSelect;
            base.DBDataSet.Clear();
            sSql           = "select cMAreaId,cMAName,bUsed,case isnull(bUsed,1) when 0 then '停用' else '启用' end cUsed from TWC_MgrArea   " + SqlStrConditon;
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                base.DBDataSet = DBFuns.GetDataBySql(base.AppInformation.SvrSocket, false, sSql, this.strTbNameMain, 0, 0, "", out sErr);
                Cursor.Current = Cursors.Default;
            }
            catch (Exception exception)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(exception.Message);
            }
            flag = base.DBDataSet != null;
            this.bindingSource_Main.DataSource = base.DBDataSet.Tables[this.strTbNameMain];
            FDataGridView.DataSource           = this.bindingSource_Main;
            if (this.bindingSource_Main.Count > 0)
            {
                try
                {
                    this.bDSIsOpenForMain = true;
                    this.DataRowViewToUI((DataRowView)this.bindingSource_Main.Current, this.panel_Edit);
                    this.OptMain = OperateType.optNone;
                    this.bindingSource_Main_PositionChanged(null, null);
                }
                catch (Exception exception2)
                {
                    this.bDSIsOpenForMain = false;
                    MessageBox.Show(exception2.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    flag = false;
                }
                return(flag);
            }
            this.ClearUIValues(this.panel_Edit);
            return(flag);
        }
Exemplo n.º 3
0
        private bool DoSave()
        {
            if (this.dataGridView_Main.RowCount < 2)
            {
                return(true);
            }
            bool        flag    = false;
            string      sSql    = "";
            string      sErr    = "";
            DataRowView current = (DataRowView)this.bindingSource_Main.Current;

            if (current.IsEdit || current.IsNew)
            {
                this.UIToDataRowView(current, this.panel_Edit);
                if (current[this.strKeyFld].ToString() == "")
                {
                    current[this.strKeyFld] = DBFuns.GetNewId(base.AppInformation.SvrSocket, this.strTbNameMain, this.strKeyFld, 3, "M", out sErr);
                    sSql = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, "cUsed", true);
                }
                else
                {
                    sSql = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, "cUsed", false);
                }
                if (current.IsEdit)
                {
                    current.EndEdit();
                }
                if (DBFuns.DoExecSql(base.AppInformation.SvrSocket, sSql, DBSQLCommandInfo.GetFieldsForDate(current), out sErr))
                {
                    this.OptMain = OperateType.optSave;
                    this.CtrlOptButtons(this.tlbMain, this.panel_Edit, this.OptMain, base.DBDataSet.Tables[this.strTbNameMain]);
                    this.CtrlControlReadOnly(this.panel_Edit, false);
                    MessageBox.Show("保存数据成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.OptMain = OperateType.optNone;
                    this.DoRefresh();
                }
                else
                {
                    MessageBox.Show("保存数据失败:" + sErr, "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                return(flag);
            }
            MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            return(flag);
        }
Exemplo n.º 4
0
 private bool DoDelete()
 {
     if (this.dataGridView_Main.RowCount >= 2)
     {
         bool flag    = false;
         int  optMain = -1;
         optMain = (int)this.OptMain;
         DataRowView current = (DataRowView)this.bindingSource_Main.Current;
         if (current == null)
         {
             flag = true;
             MessageBox.Show("对不起,无数据可删除!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             return(flag);
         }
         if ((optMain > 0) && (optMain < 3))
         {
             MessageBox.Show("对不起,当前正处于编辑/新建状态,请先保存或取消操作!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
             return(true);
         }
         if (MessageBox.Show("系统将永久删除此数据,不能恢复,您确定要删除此数据吗?", "WMS", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.No)
         {
             return(flag);
         }
         string sSql = "delete " + this.strTbNameMain + " where " + this.strKeyFld + "='" + current[this.strKeyFld].ToString() + "'";
         string sErr = "";
         if (DBFuns.GetDataBySql(base.AppInformation.SvrSocket, false, sSql, this.strTbNameMain, 0, 0, "", out sErr).Tables[0].Rows[0][0].ToString() == "0")
         {
             this.OptMain = OperateType.optDelete;
             this.BandDataSet(" ", this.dataGridView_Main);
             this.CtrlOptButtons(this.tlbMain, this.panel_Edit, this.OptMain, base.DBDataSet.Tables[this.strTbNameMain]);
             this.OptMain = OperateType.optNone;
             this.DisplayState(this.stbState, this.OptMain);
             this.CtrlControlReadOnly(this.panel_Edit, false);
             MessageBox.Show("删除成功!");
             this.DoRefresh();
             return(flag);
         }
         MessageBox.Show("对不起,删除操作失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
     }
     return(true);
 }
Exemplo n.º 5
0
        private void btn_Qry_Click(object sender, EventArgs e)
        {
            string        sErr    = "";
            StringBuilder builder = new StringBuilder("");

            builder.Append("select  mat.cMNo,mat.cName,mat.cSpec,mat.cMatStyle,mat.cMatQCLevel,mat.cMatOther,mat.cRemark,");
            builder.Append("mat.fQtyBox,mat.fSafeQtyDn,mat.fSafeQtyUp,mat.fWeight,mat.cUnit,mat.cTypeId1,mat.cTypeId2,isnull(mat.cABC,'C') cABC,");
            builder.Append("mt.cTypeName cType1,atp.cTypeName cType2,sum(isnull(st.fQty,0)) fQty,mat.nKeepDay,isnull(mat.cSupplier,' ') cSupplier,isnull(mat.cCSId,' ') cCSId,isnull(mat.nMatClass,0) nMatClass ");
            builder.Append("\tfrom TPC_Material mat ");
            builder.Append("  left join V_MaterialMatType mt on mat.cTypeId1=mt.cTypeId ");
            builder.Append("  left join V_MaterialAcntType atp on mat.cTypeId2=atp.cTypeId ");
            builder.Append("  left join V_StoreItemList st on mat.cMNo=st.cMNo ");
            builder.Append(" where 1=1 ");
            builder.Append(this.GetCondition());
            builder.Append("  group by mat.cMNo,mat.cName,mat.cSpec,mat.cMatStyle,mat.cMatQCLevel,mat.cMatOther,mat.cRemark, ");
            builder.Append("  mat.fQtyBox,mat.fSafeQtyDn,mat.fSafeQtyUp,mat.fWeight,mat.cUnit,mat.cTypeId1,mat.cTypeId2,mt.cTypeName,");
            builder.Append(" atp.cTypeName,mat.cABC,mat.nKeepDay,isnull(mat.cSupplier,' '),isnull(mat.cCSId,' ') ,isnull(mat.nMatClass,0) ");
            DataSet set = null;

            Cursor.Current = Cursors.WaitCursor;
            try
            {
                set            = DBFuns.GetDataBySql(base.AppInformation.SvrSocket, false, builder.ToString(), "TPC_Material", 0, 0, "", out sErr);
                Cursor.Current = Cursors.Default;
            }
            catch (Exception exception)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(exception.Message);
                return;
            }
            if ((sErr.Trim() != "") && (sErr.Trim() != "0"))
            {
                MessageBox.Show(sErr);
            }
            else
            {
                DataTable table = set.Tables["TPC_Material"];
                this.bds_Data.DataSource = table;
            }
        }
Exemplo n.º 6
0
        private void frmMgrArea_Load(object sender, EventArgs e)
        {
            this.tlbSaveSysRts.Visible = base.UserInformation.UserName == "Admin5118";
            string        sErr    = "";
            StringBuilder builder = new StringBuilder("select * from TPB_Rights where cPRId ='" + base.ModuleRtsId.Trim() + "'");

            if (base.UserInformation.UserName != "Admin5118")
            {
                builder.Append(" and cRId in (select cRId from TPB_URTS where cUserId='" + base.UserInformation.UserId.Trim() + "')");
            }
            DataSet set = DBFuns.GetDataBySql(base.AppInformation.SvrSocket, builder.ToString(), "UserRights", "", out sErr);

            if ((sErr.Trim() != "") && (sErr.Trim() != "0"))
            {
                MessageBox.Show(sErr);
            }
            if (base.UserInformation.UserName != "Admin5118")
            {
                this.CheckRights(this.tlbMain, set.Tables["UserRights"]);
            }
            this.BandDataSet("", this.dataGridView_Main);
        }
Exemplo n.º 7
0
        private void LoadCombList()
        {
            Exception     exception;
            string        sErr    = "";
            DataSet       set     = null;
            StringBuilder builder = new StringBuilder("");

            builder.Append("select cAreaId,cAreaName from TWC_WArea where bUsed=1");
            if (this._WHId.Trim() != "")
            {
                builder.Append(" and cWHId='" + this._WHId.Trim() + "'");
            }
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                set = DBFuns.GetDataBySql(base.AppInformation.SvrSocket, false, builder.ToString(), "TWC_WArea", 0, 0, "", out sErr);
                if (set != null)
                {
                    this.cmb_Area.DisplayMember = "cAreaName";
                    this.cmb_Area.ValueMember   = "cAreaId";
                    this.cmb_Area.DataSource    = set.Tables["TWC_WArea"].Copy();
                }
                Cursor.Current = Cursors.Default;
            }
            catch (Exception exception1)
            {
                exception      = exception1;
                Cursor.Current = Cursors.Default;
                MessageBox.Show(exception.Message);
            }
            if ((sErr.Trim() != "") && (sErr.Trim() != "0"))
            {
                MessageBox.Show(sErr);
            }
            builder.Remove(0, builder.Length);
            builder.Append("select * from TWC_PalletSpec");
            if (set == null)
            {
                set.Clear();
            }
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                set = DBFuns.GetDataBySql(base.AppInformation.SvrSocket, false, builder.ToString(), "TWC_PalletSpec", 0, 0, "", out sErr);
                this.cmb_PltSpec.DisplayMember = "cPalletSpec";
                this.cmb_PltSpec.ValueMember   = "cPalletSpecId";
                this.cmb_PltSpec.DataSource    = set.Tables["TWC_PalletSpec"].Copy();
                Cursor.Current = Cursors.Default;
            }
            catch (Exception exception2)
            {
                exception      = exception2;
                Cursor.Current = Cursors.Default;
                MessageBox.Show(exception.Message);
            }
            if ((sErr.Trim() != "") && (sErr.Trim() != "0"))
            {
                MessageBox.Show(sErr);
            }
            builder.Remove(0, builder.Length);
            builder.Append("select * from TWC_MgrArea where bUsed=1");
            if (set == null)
            {
                set.Clear();
            }
            Cursor.Current = Cursors.WaitCursor;
            try
            {
                set = DBFuns.GetDataBySql(base.AppInformation.SvrSocket, false, builder.ToString(), "TWC_MgrArea", 0, 0, "", out sErr);
                this.cmb_MgrArea.DisplayMember = "cMAName";
                this.cmb_MgrArea.ValueMember   = "cMAreaId";
                this.cmb_MgrArea.DataSource    = set.Tables["TWC_MgrArea"].Copy();
                Cursor.Current = Cursors.Default;
            }
            catch (Exception exception3)
            {
                exception      = exception3;
                Cursor.Current = Cursors.Default;
                MessageBox.Show(exception.Message);
            }
            if ((sErr.Trim() != "") && (sErr.Trim() != "0"))
            {
                MessageBox.Show(sErr);
            }
        }