/// <summary> /// 确定 /// </summary> protected void OKButton_Click(object sender, EventArgs e) { if (ORDNO.Text.Trim().Length == 0 || Seq.Text.Trim().Length == 0) { this.ShowErrorMessage("参数错误"); return; } SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; try { using (ContractProvider contProvider = new ContractProvider()) { string orno = ORDNO.Text.Trim(); string orSeq = Seq.Text.Trim(); cmd.CommandText = contProvider.DeleteZbSkSql(orno, this.CurrentStNo, orSeq); cmd.ExecuteNonQuery(); var table = ViewState["ViewDT"] as DataTable; int seq = 0; decimal total = 0; foreach (DataRow row in table.Rows) { seq++; cmd.CommandText = contProvider.InsertZbSkSql(orno, orSeq, seq.ToString(), this.CurrentStNo, row["zbskamt"].ToString(), row["zbskdate"].ToString()); cmd.ExecuteNonQuery(); total += Util.ToDecimal(row["zbskamt"].ToString()); } cmd.CommandText = contProvider.UpdateZbSkAmtSql(orno, orSeq, this.CurrentStNo, total.ToString()); cmd.ExecuteNonQuery(); } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("保存失败!" + error.Message); return; } tran.Commit(); //回调 this.DialogCallback("'CloseRefresh'", "window"); }
/// <summary> /// 否决 /// </summary> protected void RejectButton_Click(object sender, EventArgs e) { SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; using (PurProvider purProvider = new PurProvider()) { try { bool flag = false; foreach (GridViewRow row in DetailList.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { string prNo = row.Cells[1].Text.Trim(); string seq = row.Cells[2].Text.Trim(); cmd.CommandText = purProvider.RejectPr(prNo, seq); cmd.ExecuteNonQuery(); flag = true; } } if (flag) { tran.Commit(); this.BindList(); } else { this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage")); tran.Rollback(); return; } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("提交失败。" + error.Message); return; } } }
protected void SaveButton_Click(object sender, EventArgs e) { string shipNo = ShipNo.Text.Trim(); string orNo = ORDNO.Text.Trim(); #region 检测 if (shipNo.Length <= 0) { this.ShowWarningMessage("请输入出货单号"); return; } #endregion SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; using (PurProvider purProvider = new PurProvider()) { try { //仓库 var whs = purProvider.GetBaseParam("WH", "1"); string whsCode = string.Empty; if (whs != null && whs.Rows.Count > 0) { whsCode = whs.Rows[0]["description"].ToString().Trim(); } bool flag = false; foreach (GridViewRow row in List.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { string seq = row.Cells[1].Text.Trim(); string drawNo = row.Cells[2].Text.Trim(); string itemName = row.Cells[3].Text.Trim(); string rQty = row.Cells[4].Text.Trim(); string um = row.Cells[5].Text.Trim(); string planQty = row.Cells[6].Text.Trim(); //计划出货数量 string actualQty = ((TextBox)row.FindControl("shipqact")).Text.Trim(); //出货数量 #region 检测 if (actualQty.Length <= 0) { tran.Rollback(); this.ShowWarningMessage("请填写出货数量!"); return; } if (Util.ToInt(actualQty) <= 0) { tran.Rollback(); this.ShowWarningMessage("出货数量必须大于0!"); return; } if (Util.ToInt(actualQty) > Util.ToInt(planQty)) { tran.Rollback(); this.ShowWarningMessage("出货数量不能大于计划出货数量!"); return; } #endregion cmd.CommandText = purProvider.UpdateShipQtySql(shipNo, seq, Util.ToInt(actualQty)); cmd.ExecuteNonQuery(); var invTable = purProvider.GetInventoryByItem(whsCode, drawNo); if (invTable != null && invTable.Rows.Count > 0) { cmd.CommandText = purProvider.UpdateInventorySql(whsCode, drawNo, actualQty); cmd.ExecuteNonQuery(); } else { cmd.CommandText = purProvider.InsertInventorySql(whsCode, drawNo, "", "", itemName, actualQty, um); cmd.ExecuteNonQuery(); } cmd.CommandText = purProvider.InsertTransDetailSql(orNo, drawNo, whsCode, actualQty, shipNo, orNo.Substring(0, 7), "B"); cmd.ExecuteNonQuery(); cmd.CommandText = purProvider.UpdateShipStatusSql(shipNo, seq); cmd.ExecuteNonQuery(); decimal zbAmt = 0, limit = 0; //质保金 质保期限 string lastDate = string.Empty; //质保金到期日 var conTable = purProvider.GetContractInfo(orNo, seq); if (conTable != null && conTable.Rows.Count > 0) { decimal unitPrice = Util.ToDecimal(conTable.Rows[0]["unitprice"].ToString()); zbAmt = unitPrice * Util.ToDecimal(actualQty); limit = Util.ToDecimal(conTable.Rows[0]["protectterm"].ToString()); int diff = Util.ToInt(limit * 12); lastDate = LocalGlobal.ConvertDateFormat(ShipDate.Text.Trim()).AddMonths(diff).ToString("yyyy-MM-dd"); } cmd.CommandText = purProvider.InsertZhibaojinSql(shipNo, orNo, seq, itemName, drawNo, CustNo.Text.Trim(), CustName.Text.Trim(), actualQty, zbAmt.ToString(), "0", ShipDate.Text.Trim(), DateTime.Now.ToString("HH:mm:ss"), limit.ToString(), lastDate); cmd.ExecuteNonQuery(); flag = true; } } if (!flag) { this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage")); tran.Rollback(); return; } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("保存失败。" + error.Message); return; } tran.Commit(); this.ShowInfoMessage("出货成功"); this.Initialize(); this.BindList(); } }
/// <summary> /// 保存 /// </summary> protected void SaveButton_Click(object sender, EventArgs e) { #region 检测 int count = 0; foreach (GridViewRow row in PRList.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { count++; string prDate = ((TextBox)row.FindControl("PRLPDTE")).Text.Trim(); if (LocalGlobal.ConvertDateFormat(prDate) <= DateTime.Today) { this.ShowInfoMessage("日期须在明天以后!"); return; } } } if (count <= 0) { this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage")); return; } #endregion SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; var dateModel = LocalGlobal.GetDateModel(); string prNo = string.Empty; using (PurProvider purProvider = new PurProvider()) { try { if (PRNo.Text.Trim().Length == 0) //新增 { prNo = purProvider.GetMaxPRNo().ToString(); //生成新的请购单号 if (DRAWNO.Text.Trim().Length == 0) { DRAWNO.Text = " "; } } else { //修改请购单 prNo = PRNo.Text.Trim(); //先删除再添加 cmd.CommandText = purProvider.DeletePRSql(prNo); cmd.ExecuteNonQuery(); cmd.CommandText = purProvider.DeletePRDetailSql(prNo); cmd.ExecuteNonQuery(); } #region Insert cmd.CommandText = purProvider.InsertPRSql(prNo, ORDNO.Text.Trim(), DRAWNO.Text, "F", " ", "委外请购", LocalGlobal.CurrentUserID, dateModel.DateStr, LocalGlobal.CurrentUserID, dateModel.DateStr); cmd.ExecuteNonQuery(); int seq = 0; foreach (GridViewRow row in PRList.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); HtmlInputCheckBox urgentCheckControl = (HtmlInputCheckBox)row.FindControl("UrgentCheck"); if (rowCheckControl.Checked) { seq++; string isUrgent = urgentCheckControl.Checked ? "Y" : "N"; string prlstation = ((TextBox)row.FindControl("prlstation")).Text.Trim(); string prQty = ((TextBox)row.FindControl("PRLQTY")).Text.Trim(); string prDate = ((TextBox)row.FindControl("PRLPDTE")).Text.Trim(); prDate = LocalGlobal.ConvertDateFormat(prDate).ToString("yyyyMMdd"); cmd.CommandText = purProvider.InsertPRDetailSql(prNo, seq.ToString(), " ", prQty, prDate, prDate, "GT", ORDNO.Text.Trim(), "", row.Cells[3].Text.Trim(), prlstation, row.Cells[6].Text.Trim(), isUrgent, row.Cells[9].Text.Trim(), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr, "委外请购", row.Cells[7].Text.Trim()); cmd.ExecuteNonQuery(); } } #endregion if (PRNo.Text.Trim().Length > 0) { //更新状态 cmd.CommandText = purProvider.UpdatePRStatusSql(prNo, "UP"); cmd.ExecuteNonQuery(); } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("保存失败。" + error.Message); return; } tran.Commit(); PRNo.Text = prNo; PRStatus.Text = LocalGlobal.GetPRStatus(prNo); this.BindList(); } }
/// <summary> /// 提交 /// </summary> protected void PostButton_Click(object sender, EventArgs e) { #region 检测 if (PRNo.Text.Trim().Length <= 0) { this.ShowWarningMessage("请输入请购单号!"); return; } #endregion SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; using (PurProvider purProvider = new PurProvider()) { try { bool flag = false; foreach (GridViewRow row in List.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { string seq = row.Cells[2].Text.Trim(); string status = row.Cells[14].Text.Trim(); if (status == "OK") { cmd.CommandText = purProvider.PostPRDetailSql(PRNo.Text.Trim(), seq.ToString()); cmd.ExecuteNonQuery(); flag = true; } } } if (flag) { //更新状态 cmd.CommandText = purProvider.UpdatePRStatusSql(PRNo.Text.Trim(), "PS"); cmd.ExecuteNonQuery(); } else { this.ShowInfoMessage("未选中要提交的记录,请确认请购状态,或未填写价格/厂商!"); tran.Rollback(); return; } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("提交失败。" + error.Message); return; } tran.Commit(); } this.BindList(); }
protected void SaveButton_Click(object sender, EventArgs e) { #region 检测 if (PRNo.Text.Trim().Length <= 0) { this.ShowWarningMessage("请输入请购单号!"); return; } #endregion SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; var dateModel = LocalGlobal.GetDateModel(); using (PurProvider purProvider = new PurProvider()) { try { bool flag = false; foreach (GridViewRow row in List.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { string seq = row.Cells[2].Text.Trim(); string price = ((TextBox)row.FindControl("prlpacst")).Text.Trim(); string vendorNo = ((TextBox)row.FindControl("prlvnd")).Text.Trim(); string vendorName = ((TextBox)row.FindControl("prlvndm")).Text.Trim(); string curr = ((TextBox)row.FindControl("prlcur")).Text.Trim(); string isWeight = IsWeight.Checked ? "Y" : ""; #region 检测 if (Util.ToDecimal(price) <= 0) { tran.Rollback(); this.ShowWarningMessage("请填写单价"); return; } if (vendorNo.Length <= 0) { tran.Rollback(); this.ShowWarningMessage("请填写厂商代码"); return; } if (vendorName.Length <= 0) { tran.Rollback(); this.ShowWarningMessage("请填写厂商名称"); return; } #endregion cmd.CommandText = purProvider.UpdatePRDetailSql(PRNo.Text.Trim(), seq.ToString(), price, vendorNo, vendorName, curr, isWeight, dateModel.DateStr); cmd.ExecuteNonQuery(); flag = true; } } if (flag) { //更新状态 cmd.CommandText = purProvider.UpdatePRStatusSql(PRNo.Text.Trim(), "UP"); cmd.ExecuteNonQuery(); } else { this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage")); tran.Rollback(); return; } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("保存失败。" + error.Message); return; } tran.Commit(); } this.BindList(); this.PostButton.Enabled = true; }
/// <summary> /// 确定 /// </summary> protected void OKButton_Click(object sender, EventArgs e) { var totalPer = Util.ToDecimal(SCH_YF.Text.Trim()) + Util.ToDecimal(SCH_JD.Text.Trim()) + Util.ToDecimal(SCH_TH.Text.Trim()) + Util.ToDecimal(SCH_ZB.Text.Trim()); if (totalPer != 100) { this.ShowErrorMessage("比例输入不正确,请确保各项总额为100!"); return; } var signDate = LocalGlobal.ConvertDateFormat(SIGNDATE.Text.Trim()).ToString("yyyyMMdd"); var deliverDate = LocalGlobal.ConvertDateFormat(DELIVERYDATE.Text.Trim()).ToString("yyyyMMdd"); var deliverDateS = LocalGlobal.ConvertDateFormat(DELIVERYDATE.Text.Trim()).ToString("yyyy-MM-dd"); var dateModel = LocalGlobal.GetDateModel(); SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; try { using (ContractProvider contProvider = new ContractProvider()) { string stno = string.Empty, whCode = string.Empty; if (CurrentType == "2") //直接开票 { stno = LocalGlobal.NewSTNo(); //发货单号 var wh = contProvider.GetBaseParam("WH", "1"); if (wh != null && wh.Rows.Count > 0) { whCode = wh.Rows[0]["description"].ToString().Trim(); } } string orno = string.Empty; if (this.CurrentID.Length == 0) //新增 { orno = LocalGlobal.NewOrno(false); #region 合同、收款进度头表 cmd.CommandText = contProvider.InsertContractSql(orno, ORDNAME.Text.Trim(), CUSTNO.Text.Trim(), CUSTNAME.Text.Trim(), CURR.SelectedValue.Trim(), signDate, deliverDate, PROTECTTERM.SelectedValue.Trim(), SCH_YF.Text.Trim(), SCH_JD.Text.Trim(), SCH_TH.Text.Trim(), SCH_ZB.Text.Trim(), ORDAMT.Text.Trim(), Remark.Text.Trim(), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.InsertArprocessSql(orno, ORDNAME.Text.Trim(), CUSTNO.Text.Trim(), CUSTNAME.Text.Trim(), CURR.SelectedValue.Trim(), ORDAMT.Text.Trim(), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); #endregion #region 收款进度明细 cmd.CommandText = contProvider.InsertArprocessDetailSql(orno, "T1", Util.ToDecimal(ORDAMT.Text.Trim()), Util.ToDecimal(SCH_YF.Text.Trim()), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.InsertArprocessDetailSql(orno, "T2", Util.ToDecimal(ORDAMT.Text.Trim()), Util.ToDecimal(SCH_JD.Text.Trim()), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.InsertArprocessDetailSql(orno, "T3", Util.ToDecimal(ORDAMT.Text.Trim()), Util.ToDecimal(SCH_TH.Text.Trim()), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.InsertArprocessDetailSql(orno, "T4", Util.ToDecimal(ORDAMT.Text.Trim()), Util.ToDecimal(SCH_ZB.Text.Trim()), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.InsertArprocessDetailSql(orno, "T5", Util.ToDecimal(ORDAMT.Text.Trim()), 0, LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); #endregion } else //编辑 { orno = ORDNO.Text.Trim(); #region 合同、收款进度头表 cmd.CommandText = contProvider.UpdateContractSql(orno, ORDNAME.Text.Trim(), CUSTNO.Text.Trim(), CUSTNAME.Text.Trim(), CURR.SelectedValue.Trim(), signDate, deliverDate, PROTECTTERM.SelectedValue.Trim(), SCH_YF.Text.Trim(), SCH_JD.Text.Trim(), SCH_TH.Text.Trim(), SCH_ZB.Text.Trim(), ORDAMT.Text.Trim(), Remark.Text.Trim(), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.UpdateArprocessSql(orno, ORDNAME.Text.Trim(), CUSTNO.Text.Trim(), CUSTNAME.Text.Trim(), CURR.SelectedValue.Trim(), ORDAMT.Text.Trim(), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); #endregion #region 收款进度明细 cmd.CommandText = contProvider.UpdateArprocessDetailSql(orno, "T1", Util.ToDecimal(ORDAMT.Text.Trim()), Util.ToDecimal(SCH_YF.Text.Trim()), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.UpdateArprocessDetailSql(orno, "T2", Util.ToDecimal(ORDAMT.Text.Trim()), Util.ToDecimal(SCH_JD.Text.Trim()), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.UpdateArprocessDetailSql(orno, "T3", Util.ToDecimal(ORDAMT.Text.Trim()), Util.ToDecimal(SCH_TH.Text.Trim()), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.UpdateArprocessDetailSql(orno, "T4", Util.ToDecimal(ORDAMT.Text.Trim()), Util.ToDecimal(SCH_ZB.Text.Trim()), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); #endregion } if (CurrentType == "2") //直接开票 { cmd.CommandText = contProvider.DeleteKpSql(orno); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.DeleteShipSql(orno); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.DeleteTransDetailSql(orno); cmd.ExecuteNonQuery(); } #region 合同明细 cmd.CommandText = contProvider.DeleteContractDetailSql(orno); cmd.ExecuteNonQuery(); //bool flag = true; //if (List.Rows.Count == 1) //只有一行数据,判断是否是空行 //{ // var name = ((DataBoundLiteralControl)List.Rows[0].Cells[2].Controls[0]).Text.Trim(); // if (name.Length == 0) //自动创建的空行 // { // flag = false; // } //} //if (flag) //{ // for (int i = 0; i < List.Rows.Count; i++) // { // var row = List.Rows[i]; // cmd.CommandText = contProvider.InsertContractDetailSql(orno, ((Label)row.FindControl("SEQ")).Text.Trim(), ((DataBoundLiteralControl)row.Cells[2].Controls[0]).Text.Trim(), ((DataBoundLiteralControl)row.Cells[4].Controls[0]).Text.Trim(), ((DataBoundLiteralControl)row.Cells[3].Controls[0]).Text.Trim(), ((DataBoundLiteralControl)row.Cells[5].Controls[0]).Text.Trim(), ((DataBoundLiteralControl)row.Cells[6].Controls[0]).Text.Trim(), ((DataBoundLiteralControl)row.Cells[7].Controls[0]).Text.Trim(), ((DataBoundLiteralControl)row.Cells[8].Controls[0]).Text.Trim()); // cmd.ExecuteNonQuery(); // } //} var table = ViewState["ViewDT"] as DataTable; int seq = 0; foreach (DataRow row in table.Rows) { seq++; cmd.CommandText = contProvider.InsertContractDetailSql(orno, seq.ToString(), row["ITEMNO"].ToString().Trim(), row["ORDQTY"].ToString(), row["DRAWNO"].ToString(), row["UM"].ToString(), row["UNITPRICE"].ToString(), row["AMT"].ToString(), row["Remark"].ToString()); cmd.ExecuteNonQuery(); #region 直接开票 if (CurrentType == "2") //直接开票 { //1.扣减库存,写出库记录 cmd.CommandText = contProvider.InsertShipSql(stno, seq.ToString(), orno, row["DRAWNO"].ToString().Trim(), CUSTNO.Text.Trim(), CUSTNAME.Text.Trim(), row["ITEMNO"].ToString(), row["UM"].ToString(), row["ORDQTY"].ToString(), row["ORDQTY"].ToString(), row["ORDQTY"].ToString(), deliverDate, "1"); cmd.ExecuteNonQuery(); var invTable = contProvider.GetInventoryByItem(whCode, row["DRAWNO"].ToString().Trim()); if (invTable != null && invTable.Rows.Count > 0) { cmd.CommandText = contProvider.UpdateInventorySql(whCode, row["DRAWNO"].ToString().Trim(), row["ORDQTY"].ToString()); cmd.ExecuteNonQuery(); } else { cmd.CommandText = contProvider.InsertInventorySql(whCode, row["DRAWNO"].ToString().Trim(), "", "", row["ITEMNO"].ToString(), row["ORDQTY"].ToString(), row["UM"].ToString()); cmd.ExecuteNonQuery(); } cmd.CommandText = contProvider.InsertTransDetailSql(orno, row["DRAWNO"].ToString().Trim(), whCode, row["ORDQTY"].ToString(), stno, orno.Substring(0, 7), "B"); cmd.ExecuteNonQuery(); //2.开票 cmd.CommandText = contProvider.InsertKpSql(orno, seq.ToString(), "1", FP.Text.Trim(), row["ORDQTY"].ToString(), row["AMT"].ToString(), deliverDateS); cmd.ExecuteNonQuery(); } #endregion } #endregion } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("保存失败!" + error.Message); return; } tran.Commit(); //回调 this.DialogCallback("'CloseRefresh'", "window"); }
/// <summary> /// 保存 /// </summary> protected void SaveButton_Click(object sender, EventArgs e) { var table = ViewState["ViewDT"] as DataTable; if (table == null || table.Rows.Count == 0) { return; } SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; var dateModel = LocalGlobal.GetDateModel(); string prNo = string.Empty; using (PurProvider purProvider = new PurProvider()) { try { if (PRNo.Text.Trim().Length == 0) //新增 { prNo = purProvider.GetMaxPRNo().ToString(); //生成新的请购单号 cmd.CommandText = purProvider.InsertPRSql(prNo, "", "", "S", "RMB", "材料请购", LocalGlobal.CurrentUserID, dateModel.DateStr, "", "0"); cmd.ExecuteNonQuery(); PRStatus.Text = "NE"; } else { //修改请购单 prNo = PRNo.Text.Trim(); //先删除再添加 cmd.CommandText = purProvider.DeletePRDetailSql(prNo); cmd.ExecuteNonQuery(); //更新状态 cmd.CommandText = purProvider.UpdatePRStatusSql(prNo, "UP"); cmd.ExecuteNonQuery(); PRStatus.Text = "UP"; } #region Insert int seq = 0; foreach (DataRow row in table.Rows) { seq++; string prDate = row["PRLPDTE"].ToString().Trim(); prDate = LocalGlobal.ConvertDateFormat(prDate).ToString("yyyyMMdd"); cmd.CommandText = purProvider.InsertMatPRDetailSql(prNo, seq.ToString(), row["PRLQTY"].ToString().Trim(), prDate, prlwhs.Text.Trim(), row["prltno"].ToString(), row["prlstation"].ToString(), row["prlrule"].ToString(), row["prlum"].ToString(), LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr, row["prlmrk"].ToString(), row["prloutno"].ToString(), row["prlpicno"].ToString()); cmd.ExecuteNonQuery(); } #endregion } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("保存失败。" + error.Message); return; } tran.Commit(); PRNo.Text = prNo; this.BindList(); } }
protected void SaveButton_Click(object sender, EventArgs e) { #region 检测 if (ORDNO.Text.Trim().Length <= 0) { this.ShowWarningMessage("请输入工令号"); return; } #endregion SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; string shipNo = LocalGlobal.NewSTNo(); //出货单号 using (PurProvider purProvider = new PurProvider()) { try { int seq = 0; foreach (GridViewRow row in List.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { seq++; #region 检测 string noShipQty = row.Cells[6].Text.Trim(); //未出货数量 string planQty = ((TextBox)row.FindControl("shipqplan")).Text.Trim(); //计划出货数量 string shipDate = ((TextBox)row.FindControl("shipdate")).Text.Trim(); //出货日期 if (shipDate.Length <= 0) { tran.Rollback(); this.ShowWarningMessage("请填写出货日期!"); return; } if (Util.ToInt(planQty) <= 0) { tran.Rollback(); this.ShowWarningMessage("出货数量必须大于0!"); return; } if (Util.ToInt(planQty) > Util.ToInt(noShipQty)) { tran.Rollback(); this.ShowWarningMessage("出货数量不能大于未出货数量!"); return; } string orNo = List.DataKeys[row.RowIndex]["ordno"].ToString().Trim(); var morder = purProvider.GetMOrder(orNo); if (morder == null || morder.Rows.Count == 0) { var beiping = purProvider.GetBeiping(orNo); if (beiping == null || beiping.Rows.Count == 0) { tran.Rollback(); this.ShowWarningMessage("任务的号码有误!"); return; } } #endregion shipDate = LocalGlobal.ConvertDateFormat(shipDate).ToString("yyyyMMdd"); cmd.CommandText = purProvider.InsertShipSql(shipNo, seq.ToString(), orNo, row.Cells[2].Text.Trim(), CustNo.Text.Trim(), CustName.Text.Trim(), row.Cells[3].Text.Trim(), row.Cells[5].Text.Trim(), row.Cells[4].Text.Trim(), planQty, "0", shipDate, "0"); cmd.ExecuteNonQuery(); } } if (seq <= 0) { this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage")); tran.Rollback(); return; } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage("保存失败。" + error.Message); return; } tran.Commit(); ShipNo.Text = shipNo; this.BindList(); } }
/// <summary> /// 删除 /// </summary> protected void DeleteButton_Click(object sender, EventArgs e) { bool deleted = false; var dateModel = LocalGlobal.GetDateModel(); SqlConnection con = LocalGlobal.DbConnect(); con.Open(); SqlTransaction tran = con.BeginTransaction();//使用事务 SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.Transaction = tran; try { using (ContractProvider contProvider = new ContractProvider()) { foreach (GridViewRow row in List.Rows) { HtmlInputCheckBox rowCheckControl = (HtmlInputCheckBox)row.FindControl("RowCheck"); if (rowCheckControl.Checked) { string orno = List.DataKeys[row.RowIndex]["ORDNO"].ToString().Trim(); //合同 cmd.CommandText = contProvider.DeleteContractSql(orno); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.DeleteContractDetailSql(orno); cmd.ExecuteNonQuery(); //收款进度 cmd.CommandText = contProvider.DeleteArprocessSql(orno, LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); cmd.CommandText = contProvider.DeleteArprocessDetailSql(orno, LocalGlobal.CurrentUserID, dateModel.DateStr, dateModel.TimeStr); cmd.ExecuteNonQuery(); //有项被删除 deleted = true; } } } } catch (Exception error) { tran.Rollback(); this.ShowErrorMessage(this.GetGlobalResourceString("DeleteErrorMessage") + error.Message); return; } tran.Commit(); if (deleted) { this.BindList(); } else { this.ShowInfoMessage(this.GetGlobalResourceString("NotSelectMessage")); } }