/// <summary> /// 更新按钮所发生的操作 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnUpdate_Click(object sender, EventArgs e) { if (this.groupboxdrugdetail.Tag.ToString() != "") { int strDjr = InstanceForm.BCurrentUser.EmployeeId; int strDeptid = InstanceForm.BCurrentDept.DeptId; Guid strMasterid = new Guid(this.groupboxdrugdetail.Tag.ToString()); string strFph = txtFph.Text.Trim(); string strGysid = txtGys.Tag.ToString(); int err_code = 0; string err_text = ""; if (strFph == string.Empty) { MessageBox.Show("请输入发票号!再点击更新!"); txtFph.Focus(); return; } if (this.groupboxdrugdetail.Tag == null) { MessageBox.Show("请在表格在单击所要修改的行后!再点击更新!"); return; } if (string.IsNullOrEmpty(this.groupboxdrugdetail.Tag.ToString())) { MessageBox.Show("请在表格在单击所要修改的行后!再点击更新!"); return; } try { InstanceForm.BDatabase.BeginTransaction(); Yk_Ypgysfp.SaveYPgysfpUpdate( strMasterid, strGysid, strFph, strDjr, strDeptid, out err_code, out err_text, InstanceForm.BDatabase); //如果没有成功,抛出异常 if (err_code != 0) { throw new System.Exception(err_text); } //提交事务 InstanceForm.BDatabase.CommitTransaction(); } catch (System.Exception err) { InstanceForm.BDatabase.RollbackTransaction(); MessageBox.Show(err.Message); return; } MessageBox.Show("供应商调价发票更新成功!"); txtReset(); //fpgsymaster(strDeptid, strDjr); } else { } }
/// <summary> /// 点击保存按钮所发生的事件(保存主表与明细表数据) /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnSave_Click(object sender, EventArgs e) { //添加主表 Guid strMastID = Guid.Empty; Guid strdjID = Guid.Empty; if (txtypgys.Text.Trim() == "") { MessageBox.Show("请输入调价单据号!"); txtypgys.Focus(); return; } int djh = Convert.ToInt32(txtypgys.Text.Trim());//加验证 string strGysid = string.Empty; //strGysid = txtGys.Text.Trim(); strGysid = txtGys.Tag.ToString(); string strFph = txtFph.Text.Trim(); if (txtZje.Text.Trim() == "") { MessageBox.Show("总金额不能为空,请输入总金额!"); txtZje.Focus(); return; } decimal strFpZje = Convert.ToDecimal(txtZje.Text.Trim()); DateTime addtime = DateManager.ServerDateTimeByDBType(InstanceForm.BDatabase); int strDjr = InstanceForm.BCurrentUser.EmployeeId; int strDeptid = InstanceForm.BCurrentDept.DeptId; string strMemo = txtMemo.Text.Trim(); //if (strFph == string.Empty) //{ // MessageBox.Show("请输入发票号!"); // txtFph.Focus(); // return; //} //数值与空验证 if (strFpZje.ToString() == string.Empty) { MessageBox.Show("发票总金额不能为空!"); txtZje.Focus(); return; } if (Yk_Ypgysfp.GetYpgysMasterZbByDjh(InstanceForm.BCurrentDept.DeptId, Convert.ToInt32(txtypgys.Text.Trim()), InstanceForm.BDatabase)) { MessageBox.Show("此单据号已经录入数据!"); txtReset(); GetDetailinfo("0", "0"); return; } //添加明细表 int err_code = 0; string err_text = ""; DataTable tb = (DataTable)this.GrdiDetail.DataSource; if (tb.Rows.Count == 0) { MessageBox.Show("没有可保存的记录"); return; } try { InstanceForm.BDatabase.BeginTransaction(); Yk_Ypgysfp.SaveYPgysfp( // -- strMastID, strdjID, Guid.Empty, Guid.Empty, djh, strGysid, strFph, strFpZje, addtime, strDjr, strDeptid, strMemo, out strMastID, out err_code, out err_text, InstanceForm.BDatabase); //如果没有成功,抛出异常 if (err_code != 0) { throw new System.Exception(err_text); } //保存单据明细 //decimal tjhje = 0; string strdjhTemp = string.Empty; for (int i = 0; i <= tb.Rows.Count - 1; i++) { strdjhTemp = tb.Rows[0]["DJH"].ToString(); Yk_Ypgysfp.SaveYPgysfpMx( Guid.Empty, strMastID, Convert.ToInt32(tb.Rows[i]["cjid"]), Convert.ToString(tb.Rows[i]["YPPM"]), Convert.ToString(tb.Rows[i]["ypgg"]), Convert.ToString(tb.Rows[i]["ypdw"]), Convert.ToDecimal(tb.Rows[i]["YPSL"]), // Convert.ToDecimal(Math.Ceiling(tb.Rows[i]["YPSL"])), Convert.ToString(tb.Rows[i]["SCCJ"]), Convert.ToDecimal(tb.Rows[i]["Ypfj"]), //原进货价 Convert.ToDecimal(tb.Rows[i]["Ypfj"]), //新进货价 Convert.ToDecimal(tb.Rows[i]["PFJE"]), //进货价差价总金额 TPFJZJE Convert.ToDecimal(tb.Rows[i]["Ylsj"]), //原零售价 Convert.ToDecimal(tb.Rows[i]["Xlsj"]), //新零售价 Convert.ToDecimal(tb.Rows[i]["LSJE"]), //新零售价差价总金额 Convert.ToString(tb.Rows[i]["YPPH"]), Convert.ToString(tb.Rows[i]["YPPCH"]), Convert.ToString(tb.Rows[i]["SHH"]), Convert.ToInt32(tb.Rows[i]["Deptid"]), // 药品各科室 // InstanceForm.BCurrentDept.DeptId, out err_code, out err_text, InstanceForm.BDatabase ); if (err_code != 0) { throw new Exception(err_text); } } if (!String.Equals(txtypgys.Text.Trim(), strdjhTemp)) { MessageBox.Show("输入的单据号与查询出来的不一致!请正确输入单据号!"); txtypgys.Focus(); return; } //如果没有成功,抛出异常 if (err_code != 0) { throw new System.Exception(err_text); } //提交事务 InstanceForm.BDatabase.CommitTransaction(); } catch (System.Exception err) { InstanceForm.BDatabase.RollbackTransaction(); MessageBox.Show(err.Message); return; } MessageBox.Show("供应商调价发票录入成功!"); txtReset(); fpgsymaster(strDeptid, strDjr); }