Beispiel #1
0
        public void DoMSave()
        {
            string str = "";

            this.txt_cUnitId.Focus();
            DataRowView current = (DataRowView)this.bdsMain.Current;

            if (current.IsEdit || current.IsNew)
            {
                this.UIToDataRowView(current, this.pnlEdit);
                if ((current[this.strKeyFld].ToString() == "") || (current[this.strKeyFld].ToString() == "-1"))
                {
                    current[this.strKeyFld] = PubDBCommFuns.GetNewId(this.strTbNameMain, this.strKeyFld, base.UserInformation.UnitId.Trim().Length + 4, base.UserInformation.UnitId.Trim());
                    str = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, true);
                }
                else
                {
                    str = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, false);
                }
                if (current.IsEdit)
                {
                    current.EndEdit();
                }
                DBSQLCommandInfo cmdInfo = new DBSQLCommandInfo {
                    SqlText     = str,
                    FldsData    = DBSQLCommandInfo.GetFieldsForDate(current),
                    SqlType     = SqlCommandType.sctSql,
                    PageIndex   = 0,
                    PageSize    = 0,
                    FromSysType = "dotnet"
                };
                SeDBClient client = new SeDBClient();
                string     sErr   = "";
                if (client.GetDataSet(cmdInfo, out sErr).Tables[0].Rows[0][0].ToString() == "0")
                {
                    this.optMain = OperateType.optSave;
                    MessageBox.Show("保存数据成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.OpenMainDataSet();
                    this.CtrlOptButtons(this.tlbMain, this.pnlEdit, this.optMain, base.DBDataSet.Tables[this.strTbNameMain]);
                    this.optMain = OperateType.optNone;
                    this.DisplayState(this.stbState, this.optMain);
                    this.CtrlControlReadOnly(this.pnlEdit, false);
                }
                else
                {
                    MessageBox.Show("保存数据失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
            else
            {
                MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
        }
Beispiel #2
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);
        }
Beispiel #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] = PubDBCommFuns.GetNewId(this.strTbNameMain, this.strKeyFld, current["cWHId"].ToString().Trim().Length + 3, current["cWHId"].ToString());
                    sSql = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, true);
                }
                else
                {
                    sSql = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, false);
                }
                if (current.IsEdit)
                {
                    current.EndEdit();
                }
                if (PubDBCommFuns.GetDataBySql(sSql, out sErr).Tables[0].Rows[0][0].ToString() == "0")
                {
                    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;
                }
                else
                {
                    MessageBox.Show("保存数据失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                return(flag);
            }
            MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            return(flag);
        }
Beispiel #4
0
        private bool DoSave()
        {
            bool        flag    = false;
            string      sSql    = "";
            string      sErr    = "";
            DataRowView current = (DataRowView)this.bindingSource_Main.Current;

            if (current == null)
            {
                return(false);
            }
            if ((this.OptMain == OperateType.optEdit) || (this.OptMain == OperateType.optNew))
            {
                this.UIToDataRowView(current, this.panel_Edit);
                if (this.OptMain == OperateType.optNew)
                {
                    string sCode = current[this.strKeyFld].ToString();
                    if (this.bCodeIsManual)
                    {
                        if (sCode == "")
                        {
                            MessageBox.Show("对不起,代码不能为空!");
                            this.textBox_cTypeId.SelectAll();
                            this.textBox_cTypeId.Focus();
                            return(false);
                        }
                        int nCount = -1;
                        this.CheckCodeIsExists("TPC_MaterialType", "cTypeId", sCode, out nCount);
                        if (nCount < 0)
                        {
                            return(false);
                        }
                        if (nCount > 0)
                        {
                            MessageBox.Show("对不起,代码:" + sCode + " 已经存在于表:" + this.strTbNameMain + " 中!");
                            this.textBox_cTypeId.SelectAll();
                            this.textBox_cTypeId.Focus();
                            return(false);
                        }
                    }
                    else
                    {
                        current[this.strKeyFld] = PubDBCommFuns.GetNewId(this.strTbNameMain, this.strKeyFld, current["cParentId"].ToString().Trim().Length + 2, current["cParentId"].ToString().Trim());
                    }
                    sSql = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, true);
                }
                else
                {
                    sSql = DBSQLCommandInfo.GetSQLByDataRow(current, this.strTbNameMain, this.strKeyFld, false);
                }
                if (current.IsEdit)
                {
                    current.EndEdit();
                }
                if (PubDBCommFuns.GetDataBySql(sSql, DBSQLCommandInfo.GetFieldsForDate(current), out sErr).Tables[0].Rows[0][0].ToString() == "0")
                {
                    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;
                }
                else
                {
                    MessageBox.Show("保存数据失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
                return(flag);
            }
            MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            return(flag);
        }
Beispiel #5
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            string str = "";

            if (this.txt_Dtl_cMNo.Text.Trim() == "")
            {
                MessageBox.Show("对不起,物料编码不能为空!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.txt_Dtl_cMNo.Focus();
            }
            else if (this.txt_Dtl_fQty.Text.Trim() == "")
            {
                MessageBox.Show("对不起,物料数量不能为空!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.txt_Dtl_fQty.Focus();
            }
            else if (!FrmSTable.IsNumberic(this.txt_Dtl_fQty.Text.Trim()))
            {
                MessageBox.Show("对不起,物料数量为非法数值!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.txt_Dtl_fQty.SelectAll();
                this.txt_Dtl_fQty.Focus();
            }
            else if (double.Parse(this.txt_Dtl_fQty.Text.Trim()) == 0.0)
            {
                MessageBox.Show("对不起,数量不能为0");
                this.txt_Dtl_fQty.SelectAll();
                this.txt_Dtl_fQty.Focus();
            }
            else if (this.txt_Dtl_cUnit.Text.Trim() == "")
            {
                MessageBox.Show("对不起,单位不能为空!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                this.txt_Dtl_cUnit.SelectAll();
                this.txt_Dtl_cUnit.Focus();
            }
            else
            {
                if (!this.isOutBill)
                {
                }
                if (this.isOutBill && (double.Parse(this.txt_Dtl_fQty.Text.Trim()) > this.fUseQty))
                {
                    MessageBox.Show("对不起,出库数大于可出数!", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    this.txt_Dtl_fQty.SelectAll();
                    this.txt_Dtl_fQty.Focus();
                }
                else
                {
                    string  str2;
                    string  str3;
                    DataSet set;
                    this.UIToDataRowView(this.drvItem, this.pnlDtlEdit);
                    if (this.bIsNew)
                    {
                        str = this.drvItem["cBNo"].ToString();
                        this.bIsResultOK = true;
                        this.bIsShowGrid = false;
                        this.DataRowViewToUI(this.drvItem, this.pnlDtlEdit);
                        this.bIsShowGrid = true;
                        str2             = DBSQLCommandInfo.GetSQLByDataRow(this.drvItem, "TWB_BillRemoveDtl", "cBNo,cMNo", "cMName,cSpec,cMatStyle,cMatQCLevel,cMatOther,cCSId,cSupplier", true);
                        str3             = "";
                        set = PubDBCommFuns.GetDataBySql(str2, DBSQLCommandInfo.GetFieldsForDate(this.drvItem), out str3);
                        this.bIsResultOK = set.Tables[0].Rows[0][0].ToString() == "0";
                        if (this.bIsResultOK)
                        {
                            MessageBox.Show("增加明细成功!");
                            this.ClearUIValues(this.pnlDtlEdit);
                            this.drvItem["cBNo"] = str;
                            this.drvItem["cMNo"] = "";
                            this.DataRowViewToUI(this.drvItem, this.pnlDtlEdit);
                            this.txt_Dtl_cMNo.SelectAll();
                            this.txt_Dtl_cMNo.Focus();
                        }
                    }
                    else
                    {
                        this.bIsShowGrid = false;
                        this.DataRowViewToUI(this.drvItem, this.pnlDtlEdit);
                        this.bIsShowGrid = true;
                        str2             = DBSQLCommandInfo.GetSQLByDataRow(this.drvItem, "TWB_BillRemoveDtl", "cBNo,cMNo", "cMName,cSpec,cMatStyle,cMatQCLevel,cMatOther,cCSId,cSupplier", false);
                        str3             = "";
                        set = PubDBCommFuns.GetDataBySql(str2, DBSQLCommandInfo.GetFieldsForDate(this.drvItem), out str3);
                        this.bIsResultOK = set.Tables[0].Rows[0][0].ToString() == "0";
                        base.Close();
                    }
                }
            }
        }