public bool UpdateInflag(string storageCode, string type, string userName) { bool flag = true; using (SqlConnection connection = new SqlConnection(SqlHelper.ConnectionString)) { connection.Open(); SqlTransaction trans = connection.BeginTransaction(); try { StorageModel model = this.dal.GetModel(storageCode); model.inflag = true; model.IsInTime = DateTime.Now; this.dal.Update(trans, model); TreasuryStock stock = new TreasuryStock(); cn.justwin.stockBLL.StorageStock stock2 = new cn.justwin.stockBLL.StorageStock(); foreach (StorageStockModel model2 in stock2.GetGenericList("stcode = " + storageCode)) { TreasuryStockModel model3 = new TreasuryStockModel { tsid = Guid.NewGuid().ToString(), scode = model2.scode, tcode = model.tcode, sprice = model2.sprice, snumber = model2.number, isfirst = false, corp = model2.corp, incode = model2.stcode, intime = DateTime.Today, intype = 0, Type = type }; stock.Add(trans, model3); if (!model.isfirst) { string resourceId = Resource.GetResourceId(model2.scode); stock.UpdateResPrice(trans, resourceId, priceTypeId, model2.sprice, userName); } } trans.Commit(); } catch (Exception) { flag = false; trans.Rollback(); } } return(flag); }
private void Add() { string tcode = base.Request["tcode"]; foreach (GridViewRow gridViewRow in this.gvwStorageStock.Rows) { string text = gridViewRow.Cells[2].Text; decimal snumber = 0m; decimal sprice = 0m; string corp = string.Empty; if (gridViewRow.FindControl("txtNumber") is TextBox) { TextBox textBox = gridViewRow.FindControl("txtNumber") as TextBox; snumber = decimal.Parse(textBox.Text.Trim()); } if (gridViewRow.FindControl("txtPrice") is TextBox) { TextBox textBox2 = gridViewRow.FindControl("txtPrice") as TextBox; sprice = Convert.ToDecimal(textBox2.Text.Trim()); } if (gridViewRow.FindControl("hfldCorp") is HiddenField) { HiddenField hiddenField = gridViewRow.FindControl("hfldCorp") as HiddenField; corp = hiddenField.Value; } TreasuryStock treasuryStock = new TreasuryStock(); treasuryStock.Add(new TreasuryStockModel { tsid = Guid.NewGuid().ToString(), scode = text, snumber = snumber, sprice = sprice, tcode = tcode, corp = corp, isfirst = false, intime = DateTime.Now, incode = string.Empty, Type = "I" }); } this.Back(); }
public int InDepositoryConfirm(string acode, string yhdm) { DataTable table = AllocationAction.GetAllocation_StockList("sma.acode='" + acode + "' and flowstate=1 and isouta=1 "); int num = 0; TreasuryPermitBll bll = new TreasuryPermitBll(); AllocationModel model = new AllocationModel(); model = this.ReturnAllocatonModel(" acode='" + acode + "' "); if (!bll.IsPermitAccept(model.Acode, yhdm)) { return(0); } if (table.Rows.Count > 0) { TreasuryStock stock = new TreasuryStock(); TreasuryStockModel model2 = new TreasuryStockModel(); for (int i = 0; i < table.Rows.Count; i++) { model2.corp = table.Rows[i]["corp"].ToString(); model2.incode = acode; model2.intime = DateTime.Now; model2.intype = 0; model2.Type = "A"; model2.isfirst = false; model2.scode = table.Rows[i]["scode"].ToString(); model2.snumber = decimal.Parse(table.Rows[i]["number"].ToString()); model2.sprice = decimal.Parse(table.Rows[i]["sprice"].ToString()); model2.tcode = table.Rows[i]["tcodeb"].ToString(); model2.tsid = Guid.NewGuid().ToString(); if (stock.Add(model2) <= 0) { return(-1); } AllocationAction.UpdateState(true, true, acode, "In"); num = 1; } } return(num); }