public int Add(SqlTransaction trans, ModifyStockModel model) { StringBuilder builder = new StringBuilder(); builder.Append("insert into Con_Modify_Stock("); builder.Append("ModifyStockId,ModifyId,PurchaseId,Scode,Pscode,Sprice,Quantity,corp,ArrivalDate)"); builder.Append(" values ("); builder.Append("@Id,@ModifyId,@PurchaseId,@Scode,@Pscode,@Sprice,@Quantity,@Corp,@ArrivalDate)"); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.NVarChar, 70), new SqlParameter("@ModifyId", SqlDbType.NVarChar, 0x40), new SqlParameter("@PurchaseId", SqlDbType.NVarChar, 70), new SqlParameter("@Scode", SqlDbType.NVarChar, 50), new SqlParameter("@Pscode", SqlDbType.NVarChar, 0x40), new SqlParameter("@Sprice", SqlDbType.Decimal), new SqlParameter("@Quantity", SqlDbType.Decimal), new SqlParameter("@Corp", SqlDbType.NVarChar, 0x40), new SqlParameter("@ArrivalDate", SqlDbType.DateTime) }; commandParameters[0].Value = model.Id; commandParameters[1].Value = model.ModifyId; commandParameters[2].Value = model.PurchaseId; commandParameters[3].Value = model.Scode; commandParameters[4].Value = model.Pscode; commandParameters[5].Value = model.Sprice; commandParameters[6].Value = model.Quantity; commandParameters[7].Value = model.Corp; if (!model.ArrivalDate.HasValue) { commandParameters[8].Value = DBNull.Value; } else { commandParameters[8].Value = DBHelper.GetDateTime(model.ArrivalDate.Value); } if (trans == null) { return(SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters)); } return(SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters)); }
public void Update(SqlTransaction trans, ModifyStockModel model) { StringBuilder builder = new StringBuilder(); builder.Append("Update Con_Modify_Stock "); builder.Append("SET Sprice=@Sprice,Quantity=@Quantity,corp=@Corp"); builder.Append(" WHERE ModifyStockId=@Id "); SqlParameter[] commandParameters = new SqlParameter[] { new SqlParameter("@Id", SqlDbType.NVarChar, 70), new SqlParameter("@Sprice", SqlDbType.Decimal), new SqlParameter("@Quantity", SqlDbType.Decimal), new SqlParameter("@Corp", SqlDbType.NVarChar, 0x40) }; commandParameters[0].Value = model.Id; commandParameters[1].Value = model.Sprice; commandParameters[2].Value = model.Quantity; commandParameters[3].Value = model.Corp; if (trans == null) { SqlHelper.ExecuteNonQuery(CommandType.Text, builder.ToString(), commandParameters); } else { SqlHelper.ExecuteNonQuery(trans, CommandType.Text, builder.ToString(), commandParameters); } }
private void AddPurchaseStock(SqlTransaction trans, PurchaseModel model, string modifyStockAction) { this.UpdatePurchaseplanStockDataSource(); DataTable dataTable = this.ViewState["resource"] as DataTable; if (modifyStockAction == "add") { DataRow[] array = dataTable.Select("pscode=" + model.pcode); for (int i = 0; i < array.Length; i++) { DataRow dataRow = array[i]; ModifyStockModel modifyStockModel = new ModifyStockModel(); modifyStockModel.Id = Guid.NewGuid().ToString(); modifyStockModel.ModifyId = this.hfldModifyId.Value.Trim(); if (!string.IsNullOrEmpty(dataRow["psid"].ToString())) { modifyStockModel.PurchaseId = dataRow["psid"].ToString(); } else { modifyStockModel.PurchaseId = Guid.NewGuid().ToString(); } modifyStockModel.Scode = dataRow["ResourceCode"].ToString(); modifyStockModel.Pscode = dataRow["pscode"].ToString(); modifyStockModel.Quantity = Convert.ToDecimal(dataRow["number"]); modifyStockModel.Sprice = Convert.ToDecimal(dataRow["sprice"]); modifyStockModel.Corp = dataRow["corp"].ToString(); if (dataRow["ArrivalDate"] != DBNull.Value) { modifyStockModel.ArrivalDate = new DateTime?(Convert.ToDateTime(dataRow["ArrivalDate"])); } else { modifyStockModel.ArrivalDate = null; } this.modifyStock.Add(trans, modifyStockModel); } return; } if (modifyStockAction == "edit") { DataRow[] array2 = dataTable.Select("pscode=" + model.pcode + "and ModifyStockId<>''"); for (int j = 0; j < array2.Length; j++) { DataRow dataRow2 = array2[j]; ModifyStockModel modifyStockModel2 = new ModifyStockModel(); modifyStockModel2.Id = dataRow2["ModifyStockId"].ToString(); modifyStockModel2.ModifyId = this.hfldModifyId.Value.Trim(); modifyStockModel2.PurchaseId = dataRow2["psid"].ToString(); modifyStockModel2.Pscode = dataRow2["pscode"].ToString(); modifyStockModel2.Quantity = Convert.ToDecimal(dataRow2["number"]); modifyStockModel2.Sprice = Convert.ToDecimal(dataRow2["sprice"]); modifyStockModel2.Corp = dataRow2["corp"].ToString(); this.modifyStock.Update(trans, modifyStockModel2); } if (this.ViewState["modifyStockIds"] != null) { List <string> ids = (List <string>) this.ViewState["modifyStockIds"]; this.modifyStock.Delete(trans, ids); } DataRow[] array3 = dataTable.Select("pscode=" + model.pcode); for (int k = 0; k < array3.Length; k++) { DataRow dataRow3 = array3[k]; if (string.IsNullOrEmpty(dataRow3["ModifyStockId"].ToString())) { ModifyStockModel modifyStockModel3 = new ModifyStockModel(); modifyStockModel3.Id = Guid.NewGuid().ToString(); modifyStockModel3.ModifyId = this.hfldModifyId.Value.Trim(); modifyStockModel3.PurchaseId = Guid.NewGuid().ToString(); modifyStockModel3.Scode = dataRow3["ResourceCode"].ToString(); modifyStockModel3.Pscode = dataRow3["pscode"].ToString(); modifyStockModel3.Quantity = Convert.ToDecimal(dataRow3["number"]); modifyStockModel3.Sprice = Convert.ToDecimal(dataRow3["sprice"]); modifyStockModel3.Corp = dataRow3["corp"].ToString(); if (dataRow3["ArrivalDate"] != DBNull.Value) { modifyStockModel3.ArrivalDate = new DateTime?(Convert.ToDateTime(dataRow3["ArrivalDate"])); } else { modifyStockModel3.ArrivalDate = null; } this.modifyStock.Add(trans, modifyStockModel3); } } } }
public void Update(SqlTransaction trans, ModifyStockModel model) { this.dal.Update(trans, model); }
public void Add(SqlTransaction trans, ModifyStockModel model) { this.dal.Add(trans, model); }
public void Add(ModifyStockModel model) { this.dal.Add(null, model); }