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 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); }
private bool DoSave() { 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, 7, ""); 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; return(flag); } 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); }
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(); } } } }
public void DoMSave() { string sSql = ""; txt_cUserId.Focus();//使其焦点移开,修改数据能及时更新 DataRowView drvX = (DataRowView)bdsMain.Current; if (drvX.IsEdit || drvX.IsNew) { if (this.txt_cCmptId.Text.Trim() == "") { MessageBox.Show("单位编码不能为空!"); txt_cCmptId.Focus(); return; } if (this.txt_cName.Text.Trim() == "") { MessageBox.Show("用户名称不能为空!"); txt_cName.Focus(); return; } if (this.cmb_bUsed.Text.Trim() == "") { MessageBox.Show("是否启用不能为空!"); cmb_bUsed.Focus(); return; } if (this.cmb_nTag.Text.Trim() == "") { MessageBox.Show("用户类型不能为空!"); cmb_nTag.Focus(); return; } if (this.txt_nSort.Text.Trim() == "") { MessageBox.Show("排序号不能为空!"); txt_nSort.Focus(); return; } int iX = (int)UserInformation.UType; if (cmb_nTag.SelectedIndex > iX) { MessageBox.Show("对不起,当前用户的权限超出里您的权限范围,请重选用户类型!"); cmb_nTag.Focus(); return; } UIToDataRowView(drvX, pnlEdit); //保存拼音简码和五笔简码 string sX = ""; if (drvX["cName"] != null) { sX = drvX["cName"].ToString(); sX = Zqm.Text.TextPYWB.GetWBPY(sX, PYWBType.pwtPYFirst); } if (drvX["cPYJM"] != null) { drvX["cPYJM"] = sX; } sX = ""; if (drvX["cName"] != null) { sX = drvX["cName"].ToString(); sX = Zqm.Text.TextPYWB.GetWBPY(sX, PYWBType.pwtWBFirst); } if (drvX["cWBJM"] != null) { drvX["cWBJM"] = sX; } if (drvX[strKeyFld].ToString() == "" || drvX[strKeyFld].ToString() == "-1") //新增,需要产生新的号码 { drvX[strKeyFld] = SunEast.App.PubDBCommFuns.GetNewId(strTbNameMain, strKeyFld, 8, drvX["cDeptId"].ToString().Trim()); sSql = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drvX, strTbNameMain, strKeyFld, true);//产生 insert 语句 } else { sSql = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drvX, strTbNameMain, strKeyFld, false);//产生UPDATE 语句 } bool bX = false; //检测完整性 string sErr = ""; if (!CheckInputDataValues(drvX, pnlEdit, "cUserId,cName,bUsed,nTag,nSort", out sErr)) { MessageBox.Show(sErr); return; } if (drvX.IsEdit) { drvX.EndEdit(); } DataSet dsX = null; //执行语句 dsX = SunEast.App.PubDBCommFuns.GetDataBySql(sSql, DBSQLCommandInfo.GetFieldsForDate(drvX), out sErr); //dsX = SunEast.App.PubDBCommFuns.GetDataBySql(sSql, out sErr); bX = dsX.Tables[0].Rows[0][0].ToString() == "0"; if (bX) { optMain = OperateType.optSave; MessageBox.Show("保存数据成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); //重新刷新数据 OpenMainDataSet(sbConndition.ToString()); //控制录入问题 CtrlOptButtons(this.tlbMain, pnlEdit, optMain, DBDataSet.Tables[strTbNameMain]); optMain = OperateType.optNone; DisplayState(stbState, optMain); CtrlControlReadOnly(pnlEdit, false); } else { MessageBox.Show("保存数据失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void DoMSave() { DataRowView drvMEx = null; string sSqlMainEx = ""; txt_cBNo.Focus();//使其焦点移开,修改数据能及时更新 if (cmb_cCreator.Text.Trim() == "" || cmb_cCreator.SelectedValue == null) { MessageBox.Show("对不起,仓管员不能为空!"); cmb_cCreator.Focus(); return; } DataRowView drvX = (DataRowView)bdsMain.Current; if ((optMain == OperateType.optNew) || (optMain == OperateType.optEdit)) { bool bX = false; if (drvX.IsEdit) { drvX.EndEdit(); } UIToDataRowView(drvX, pnlEdit); string sql = ""; if (optMain == OperateType.optNew) { drvX["cBNo"] = GetNewId(); sql = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drvX, strTbNameMain, "cBNo", true); } else { sql = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drvX, strTbNameMain, "cBNo", false); } string err = ""; DataSet ds = PubDBCommFuns.GetDataBySql(AppInformation.SvrSocket, sql, DBSQLCommandInfo.GetFieldsForDate(drvX), out err); //if (drvX.IsEdit) drvX.EndEdit(); //DataMainToObjInfo(drvX); //bX = BI.BSIOBillBI.BSIOBillBI.DoIOBillInMain(AppInformation.dbtApp, AppInformation.AppConn, UserInformation, drvX, false) == "0"; if (ds.Tables[0].Rows[0].ItemArray[0].ToString() == "0") { optMain = OperateType.optSave; MessageBox.Show("保存主表数据成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); //重新刷新数据 //btnQry_Click(null, null); ((DataTable)bdsMain.DataSource).AcceptChanges(); bdsMain_PositionChanged(null, null); //控制录入问题 CtrlOptButtons(this.tlbMain, pnlEdit, optMain, (DataTable)bdsMain.DataSource); optMain = OperateType.optNone; //DisplayState(stbState, optMain); CtrlControlReadOnly(pnlEdit, false); } else { MessageBox.Show("保存主表数据失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public void DoMSave() { string sSql = ""; txt_cDeptId.Focus();//使其焦点移开,修改数据能及时更新 DataRowView drvX = (DataRowView)bdsMain.Current; if (drvX.IsEdit || drvX.IsNew) { if (txt_cCmptId.Text.Trim() == "") { MessageBox.Show("单位编码不能为空!"); txt_cCmptId.Focus(); return; } //if (this.txt_cDeptId.Text.Trim() == "") //{ // MessageBox.Show("部门编码不能为空!"); // txt_cDeptId.Focus(); // return; //} if (this.txt_cName.Text.Trim() == "") { MessageBox.Show("部门名称不能为空!"); txt_cName.Focus(); return; } UIToDataRowView(drvX, pnlEdit); if (drvX[strKeyFld].ToString() == "" || drvX[strKeyFld].ToString() == "-1") //新增,需要产生新的号码 { //drvX[strKeyFld] = SunEast.App.PubDBCommFuns.GetNewId(strTbNameMain, strKeyFld, 3, "1"); string sXX = drvX["cCmptId"].ToString().Trim(); drvX[strKeyFld] = SunEast.App.PubDBCommFuns.GetNewId(strTbNameMain, strKeyFld, 5, sXX); sSql = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drvX, strTbNameMain, strKeyFld, true);//产生 insert 语句 } else { sSql = DBCommInfo.DBSQLCommandInfo.GetSQLByDataRow(drvX, strTbNameMain, strKeyFld, false);//产生UPDATE 语句 } bool bX = false; if (drvX.IsEdit) { drvX.EndEdit(); } DBCommInfo.DBSQLCommandInfo cmdInfo = new DBSQLCommandInfo(); //执行命令的对象 cmdInfo.SqlText = sSql; //SQL语句 或 存储过程名 若有参数,另外在参数集里增加 cmdInfo.FldsData = DBSQLCommandInfo.GetFieldsForDate(drvX); 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; dsX = sdcX.GetDataSet(cmdInfo, out sErr); //通过获取服务器数据对象的GetDataSet方法获取数据 bX = dsX.Tables[0].Rows[0][0].ToString() == "0"; if (bX) { optMain = OperateType.optSave; MessageBox.Show("保存数据成功!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); //重新刷新数据 OpenMainDataSet(sbConndition.ToString()); //控制录入问题 CtrlOptButtons(this.tlbMain, pnlEdit, optMain, DBDataSet.Tables[strTbNameMain]); optMain = OperateType.optNone; DisplayState(stbState, optMain); CtrlControlReadOnly(pnlEdit, false); } else { MessageBox.Show("保存数据失败!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } } else { MessageBox.Show("对不起,当前没有处于编辑状态!", "", MessageBoxButtons.OK, MessageBoxIcon.Information); } }