private bool DoSave() { if (dataGridView_Main.RowCount < 2) { return(true); } bool Result = false; string sqlStr = ""; string errStr = ""; DataRowView drv = (DataRowView)bindingSource_Main.Current; if (drv.IsEdit || drv.IsNew) { UIToDataRowView(drv, panel_Edit); if (drv[strKeyFld].ToString() == "") { drv[strKeyFld] = PubDBCommFuns.GetNewId(strTbNameMain, strKeyFld, 5, UserInformation.UnitId); sqlStr = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drv, strTbNameMain, strKeyFld, true); } else { sqlStr = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drv, strTbNameMain, strKeyFld, false); } if (drv.IsEdit) { drv.EndEdit(); } DataSet ds = null; ds = PubDBCommFuns.GetDataBySql(sqlStr, out errStr); bool b = DBDataSet.Tables[0].Rows[0][0].ToString() == "0"; if (b) { OptMain = OperateType.optSave; try { CtrlOptButtons(this.tlbMain, panel_Edit, OptMain, DBDataSet.Tables[strTbNameMain]); } catch (Exception e) { MessageBox.Show(e.Message); } CtrlControlReadOnly(panel_Edit, false); MessageBox.Show("保存数据成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); OptMain = OperateType.optNone; } else { MessageBox.Show("保存数据失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(Result); }
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); } }
private bool DoSaveDetail() { if (dataGridView_Detail.RowCount < 2) { return(true); } bool Result = false; string sqlStr = ""; string errStr = ""; DataRowView drv = (DataRowView)bindingSource_Detail.Current; if (drv.IsEdit || drv.IsNew) { //UIToDataRowView(drv, panel_Edit); if (drv[strKeyFld].ToString() == "") { drv[strKeyFld] = PubDBCommFuns.GetNewId(strTbNameDetail, strKeyFld, 5, UserInformation.UnitId); sqlStr = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drv, strTbNameDetail, strKeyFld, true); } else { //sqlStr = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drv, strTbNameDetail, strKeyFld, false); sqlStr = "Update TWB_BillCheckDtl set fRQty=" + drv["fRQty"] + ",fDiff=" + drv["fQty"] + "-" + drv["fRQty"] + " where cBNo='" + drv["cBNo"] + "' and nPalletId='" + drv["nPalletId"] + "' and cBoxId='" + drv["cBoxId"] + "' and cMNo='" + drv["cMNo"] + "' and cBatchNo='" + drv["cBatchNo"] + "' and nQCStatus='" + drv["nQCStatus"] + "'"; } if (drv.IsEdit) { drv.EndEdit(); } DataSet ds = null; ds = PubDBCommFuns.GetDataBySql(sqlStr, out errStr); bool b = ds.Tables[0].Rows[0][0].ToString() == "0"; if (b) { OptDetail = OperateType.optSave; // CtrlOptButtons(this.tlbMain, panel_Edit, OptMain, DBDataSet.Tables[strTbNameMain]); // CtrlControlReadOnly(panel_Edit, false); MessageBox.Show("保存数据成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); OptDetail = OperateType.optNone; } else { MessageBox.Show("保存数据失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } return(Result); }
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); }
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); }