private void save(string v) { string strImg = dataUrl.Value.ToString(); using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); try { foreach (GridViewRow gridViewRow in this.gvOutReserve.Rows) { CheckBox checkBox = gridViewRow.FindControl("cbBox") as CheckBox; if (checkBox != null && checkBox.Checked) { List <OutStockModel> listArray = this.outStockBll.GetListArray(" where orcode='" + checkBox.ToolTip + "'"); OutReserveModel model = this.outReserveBll.GetModel(checkBox.ToolTip); foreach (OutStockModel current in listArray) { List <TreasuryStockModel> listArray2 = this.treasuryStockBll.GetListArray(string.Concat(new object[] { " where scode='", current.scode, "' and sprice=", current.sprice, " and corp='", current.corp, "' and tcode='", model.tcode, "' order by intime asc" })); decimal num = 0m; foreach (TreasuryStockModel current2 in listArray2) { num += current2.snumber; } if (current.number > num) { base.RegisterScript("alert('库存量不足!!')"); //base.RegisterScript("location='QOutReserve.aspx?prjGuid=" + base.Request["prjGuid"].ToString() + "'"); if (v == "wx") { base.RegisterScript("location='QOutReserveWX.aspx?prjGuid=" + base.Request["prjGuid"].ToString() + "'"); } if (v == "pc") { base.RegisterScript("location='QOutReserve.aspx?prjGuid=" + base.Request["prjGuid"].ToString() + "'"); } return; } foreach (TreasuryStockModel current3 in listArray2) { if (current3.snumber >= current.number) { current3.snumber -= current.number; if (current3.snumber == 0m) { this.treasuryStockBll.Delete(current3.tsid); } else { this.treasuryStockBll.Update(current3); } Common2.AlarmMethod(current3.tcode, current3.scode); break; } if (current3.snumber < current.number) { current.number -= current3.snumber; this.treasuryStockBll.Delete(current3.tsid); } } } OutReserveModel model2 = this.outReserveBll.GetModel(checkBox.ToolTip); model2.isout = true; model2.IsOutTime = DateTime.Now; model2.writeName = strImg; int num2 = this.outReserveBll.Update(null, model2); if (num2 > 0) { base.RegisterScript("alert('系统提示:\\n\\n操作成功');"); } else { base.RegisterScript("alert('系统提示:\\n\\n操作失败');"); } } } } catch (Exception) { sqlTransaction.Rollback(); base.RegisterScript("alert('系统提示:\\n\\n出库出现异常,出库失败!');"); } } if (v == "wx") { base.RegisterScript("location='QOutReserveWX.aspx?prjGuid=" + base.Request["prjGuid"].ToString() + "'"); } if (v == "pc") { base.RegisterScript("location='QOutReserve.aspx?prjGuid=" + base.Request["prjGuid"].ToString() + "'"); } }
public int OutDepositoryConfirm(string acode, string yhdm) { DataTable table = AllocationAction.GetAllocation_StockList("sma.acode='" + acode + "' and flowstate=1 "); DataTable materialDetailsOfDeposity = new DataTable(); int num = 0; decimal num2 = 0M; TreasuryPermitBll bll = new TreasuryPermitBll(); for (int i = 0; i < table.Rows.Count; i++) { decimal num4 = 0M; bool flag = bll.IsPermitBool(table.Rows[i]["tcodea"].ToString(), yhdm); object materialNumberOfDepository = AllocationAction.GetMaterialNumberOfDepository(table.Rows[i]["tcodea"].ToString(), " scode='" + table.Rows[i]["scode"].ToString() + "' and sprice='" + table.Rows[i]["sprice"].ToString() + "' and corp='" + table.Rows[i]["corp"].ToString() + "' "); if (!flag) { num = -3; break; } if (materialNumberOfDepository != null) { num4 = decimal.Parse(materialNumberOfDepository.ToString()); } num2 = decimal.Parse(table.Rows[i]["number"].ToString()); if (num4 < num2) { num = -2; break; } } switch (num) { case -2: case -3: return(num); default: for (int j = 0; j < table.Rows.Count; j++) { decimal num6 = 0M; num6 = decimal.Parse(table.Rows[j]["number"].ToString()); materialDetailsOfDeposity = AllocationAction.GetMaterialDetailsOfDeposity("tcode='" + table.Rows[j]["tcodea"].ToString() + "' and scode='" + table.Rows[j]["scode"].ToString() + "' and sprice='" + table.Rows[j]["sprice"].ToString() + "' and corp='" + table.Rows[j]["corp"].ToString() + "' order by intime asc "); for (int k = 0; k < materialDetailsOfDeposity.Rows.Count; k++) { decimal num8 = 0M; num8 = decimal.Parse(materialDetailsOfDeposity.Rows[k]["snumber"].ToString()); if (num8 > num6) { if (AllocationAction.UpdateNumberOfTreasury(materialDetailsOfDeposity.Rows[k]["tsid"].ToString(), num8 - num6) <= 0) { num = -1; } else { Common2.AlarmMethod(table.Rows[j]["tcodea"].ToString(), table.Rows[j]["scode"].ToString()); } break; } if (num8 == num6) { if (new TreasuryStock().Delete(materialDetailsOfDeposity.Rows[k]["tsid"].ToString()) <= 0) { num = -1; } else { Common2.AlarmMethod(table.Rows[j]["tcodea"].ToString(), table.Rows[j]["scode"].ToString()); } break; } if (num8 < num6) { if (new TreasuryStock().Delete(materialDetailsOfDeposity.Rows[k]["tsid"].ToString()) <= 0) { num = -1; break; } num6 -= num8; Common2.AlarmMethod(table.Rows[j]["tcodea"].ToString(), table.Rows[j]["scode"].ToString()); } } if (num == -1) { break; } num = 1; } break; } if (num == 1) { AllocationAction.UpdateState(true, false, acode, "Out"); } return(num); }
protected void btnOk_Click(object sender, System.EventArgs e) { using (SqlConnection sqlConnection = new SqlConnection(SqlHelper.ConnectionString)) { sqlConnection.Open(); SqlTransaction sqlTransaction = sqlConnection.BeginTransaction(); try { foreach (GridViewRow gridViewRow in this.gvWastage.Rows) { CheckBox checkBox = gridViewRow.FindControl("cbBox") as CheckBox; if (checkBox != null && checkBox.Checked) { System.Collections.Generic.List <SmWastageStockModel> listArray = this.smWastageStockBll.GetListArray(" where WastageCode='" + checkBox.ToolTip + "' "); SmWastageModel modelByCode = this.smWastageBll.GetModelByCode(checkBox.ToolTip); foreach (SmWastageStockModel current in listArray) { System.Collections.Generic.List <TreasuryStockModel> listArray2 = this.treasuryStockBll.GetListArray(string.Concat(new object[] { " where scode='", current.ResourceCode, "' and sprice=", current.Sprice, " and ISNULL(corp,'')='", current.Corp, "' and tcode='", modelByCode.Treasurycode, "' order by intime asc" })); decimal num = 0m; foreach (TreasuryStockModel current2 in listArray2) { num += current2.snumber; } if (current.Number > num) { base.RegisterScript("top.ui.alert('库存量不足!')"); base.RegisterScript("location='ConfirmWastage.aspx'"); return; } foreach (TreasuryStockModel current3 in listArray2) { if (current3.snumber >= current.Number) { current3.snumber -= current.Number; if (current3.snumber == 0m) { this.treasuryStockBll.Delete(current3.tsid); } else { this.treasuryStockBll.Update(current3); } Common2.AlarmMethod(current3.tcode, current3.scode); break; } if (current3.snumber < current.Number) { current.Number -= current3.snumber; this.treasuryStockBll.Delete(current3.tsid); } } } SmWastageModel modelByCode2 = this.smWastageBll.GetModelByCode(checkBox.ToolTip); modelByCode2.Isout = true; modelByCode2.IsOutTime = new System.DateTime?(System.DateTime.Now); int num2 = this.smWastageBll.Update(null, modelByCode2); if (num2 > 0) { base.RegisterScript("top.ui.show('操作成功');"); } else { base.RegisterScript("top.ui.show('操作失败');"); } } } } catch (System.Exception) { sqlTransaction.Rollback(); base.RegisterScript("top.ui.alert('出库出现异常,出库失败!');"); } } base.RegisterScript("location='ConfirmWastage.aspx'"); }