/// <summary> /// 生成新发货单号 /// </summary> /// <returns></returns> public static string NewSTNo() { var dateModel = GetDateModel(); string no = string.Empty; using (PurProvider purProvider = new PurProvider()) { var param = purProvider.GetBaseParam("ST", "NO"); if (param != null && param.Rows.Count > 0) { string stno = param.Rows[0]["description"].ToString(); //ST1703997 string year = stno.Substring(2, 2); string num = stno.Substring(4, 5); if (dateModel.YearStr == year) { no = "ST" + year + (Util.ToInt(num) + 1).ToString().PadLeft(5, '0'); } else { no = "ST" + dateModel.YearStr + (Util.ToInt(num) + 1).ToString().PadLeft(5, '0'); } } else { no = "ST" + dateModel.YearStr + "00001"; } purProvider.UpdateBaseParam("ST", "NO", no); } return(no); }
/// <summary> /// 初始化 /// </summary> private void Initialize() { #region 页面内容 using (PurProvider purProvider = new PurProvider()) { var bomType = purProvider.GetBaseParam("PT", ""); LocalGlobal.BindListItems(BomType, bomType.DefaultView, "Description", "code", true); } this.ORDNO.Text = string.Empty; this.DRAWNO.Text = string.Empty; this.PRNo.Text = string.Empty; this.PRStatus.Text = string.Empty; //this.BomType.SelectedIndex = -1; #endregion //绑定列表 //this.BindList(); }
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(); } }