/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Consumption model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update mtms_Consumption set "); strSql.Append(" Name = @Name , "); strSql.Append(" TransportOrderId = @TransportOrderId , "); strSql.Append(" Money = @Money "); strSql.Append(" where Id=@Id "); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4), new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@TransportOrderId", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Decimal, 9) }; parameters[0].Value = model.Id; parameters[1].Value = model.Name; parameters[2].Value = model.TransportOrderId; parameters[3].Value = model.Money; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return(true); } else { return(false); } }
/// <summary> /// 获得数据列表 /// </summary> public List <Model.Consumption> DataTableToList(DataTable dt) { List <Model.Consumption> modelList = new List <Model.Consumption>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Consumption model; for (int n = 0; n < rowsCount; n++) { model = new Model.Consumption(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.Name = dt.Rows[n]["Name"].ToString(); if (dt.Rows[n]["TransportOrderId"].ToString() != "") { model.TransportOrderId = int.Parse(dt.Rows[n]["TransportOrderId"].ToString()); } if (dt.Rows[n]["Money"].ToString() != "") { model.Money = decimal.Parse(dt.Rows[n]["Money"].ToString()); } modelList.Add(model); } } return(modelList); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Consumption model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into mtms_Consumption("); strSql.Append("Name,TransportOrderId,Money"); strSql.Append(") values ("); strSql.Append("@Name,@TransportOrderId,@Money"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@TransportOrderId", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Decimal, 9) }; parameters[0].Value = model.Name; parameters[1].Value = model.TransportOrderId; parameters[2].Value = model.Money; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return(0); } else { return(Convert.ToInt32(obj)); } }
/// <summary> /// 获得数据列表 /// </summary> public List<Model.Consumption> DataTableToList(DataTable dt) { List<Model.Consumption> modelList = new List<Model.Consumption>(); int rowsCount = dt.Rows.Count; if (rowsCount > 0) { Model.Consumption model; for (int n = 0; n < rowsCount; n++) { model = new Model.Consumption(); if (dt.Rows[n]["Id"].ToString() != "") { model.Id = int.Parse(dt.Rows[n]["Id"].ToString()); } model.Name = dt.Rows[n]["Name"].ToString(); if (dt.Rows[n]["TransportOrderId"].ToString() != "") { model.TransportOrderId = int.Parse(dt.Rows[n]["TransportOrderId"].ToString()); } if (dt.Rows[n]["Money"].ToString() != "") { model.Money = decimal.Parse(dt.Rows[n]["Money"].ToString()); } modelList.Add(model); } } return modelList; }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Consumption GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, Name, TransportOrderId, Money "); strSql.Append(" from mtms_Consumption "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int, 4) }; parameters[0].Value = Id; Model.Consumption model = new Model.Consumption(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["TransportOrderId"].ToString() != "") { model.TransportOrderId = int.Parse(ds.Tables[0].Rows[0]["TransportOrderId"].ToString()); } if (ds.Tables[0].Rows[0]["Money"].ToString() != "") { model.Money = decimal.Parse(ds.Tables[0].Rows[0]["Money"].ToString()); } return(model); } else { return(null); } }
public int Add(SqlConnection conn, SqlTransaction trans, Model.Consumption model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into mtms_Consumption("); strSql.Append("Name,TransportOrderId,Money"); strSql.Append(") values ("); strSql.Append("@Name,@TransportOrderId,@Money"); strSql.Append(") "); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@Name", SqlDbType.VarChar, 254), new SqlParameter("@TransportOrderId", SqlDbType.Int, 4), new SqlParameter("@Money", SqlDbType.Decimal, 9) }; parameters[0].Value = model.Name; parameters[1].Value = model.TransportOrderId; parameters[2].Value = model.Money; return(DbHelperSQL.ExecuteSql(conn, trans, strSql.ToString(), parameters)); }
private bool DoEdit(int _id) { bool result = false; BLL.TransportOrder bll = new BLL.TransportOrder(); Model.TransportOrder model = bll.GetModel(_id); model.FactBackTime = Utils.StrToDateTime(txtFactBackTime.Text.Trim(), DateTime.Now); model.Repayment = Utils.StrToDecimal(txtRepayment.Text.Trim(), 0.00M); model.FactRepayment = Utils.StrToDecimal(txtFactRepayment.Text.Trim(), 0.00M); model.Carriage = Utils.StrToDecimal(txtCarriage.Text.Trim(), 0.00M); model.Status = 2; string[] itemIds = Request.Params.GetValues("transportOrderItemId"); string[] factDispatchCounts = Request.Params.GetValues("factDispatchCount"); string[] factReceivedCounts = Request.Params.GetValues("factReceivedCount"); string[] totalPrices = Request.Params.GetValues("totalPrice"); string[] roundStatus = Request.Params.GetValues("roundStatus"); string[] costItemNames = Request.Params.GetValues("costItemName"); string[] monies = Request.Params.GetValues("money"); List<Model.TransportOrderItem> item_list = new List<Model.TransportOrderItem>(); BLL.TransportOrderItem itemBll = new BLL.TransportOrderItem(); Model.TransportOrderItem item; List<Model.Order> orders = new List<Model.Order>(); BLL.Order orderBll = new BLL.Order(); Model.Order order; for (int i = 0; i < itemIds.Length; i++) { item = itemBll.GetModel(Utils.StrToInt(itemIds[i], 0)); if (item != null) { decimal oldFactDispatchCount = item.FactDispatchCount; decimal newFactDispatchCount = Utils.StrToDecimal(factDispatchCounts[i], 0.00M); order = orderBll.GetModel(item.OrderId); order.DispatchedCount += newFactDispatchCount - oldFactDispatchCount; orders.Add(order); item.FactDispatchCount = newFactDispatchCount; item.FactReceivedCount = Utils.StrToDecimal(factReceivedCounts[i], 0.00M); item.TotalPrice = Utils.StrToDecimal(totalPrices[i], 0.00M); item.RoundStatus = roundStatus[i]; item_list.Add(item); } } List<Model.Consumption> consumption_list = new List<Model.Consumption>(); for (int i = 0; i < costItemNames.Length; i++) { Model.Consumption consumption = new Model.Consumption(); consumption.Name = costItemNames[i]; consumption.Money = Utils.StrToDecimal(monies[i], 0.00M); consumption.TransportOrderId = _id; consumption_list.Add(consumption); } if (bll.Update(model, item_list, consumption_list, orders)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "回车报账信息:" + model.Code); //记录日志 result = true; } return result; }
private bool DoEdit(int _id) { bool result = false; BLL.TransportOrder bll = new BLL.TransportOrder(); Model.TransportOrder model = bll.GetModel(_id); model.FactArriveDate = Utils.StrToDateTime(txtFactArriveDate.Text.Trim(), DateTime.Now); model.FactBackTime = Utils.StrToDateTime(txtFactBackTime.Text.Trim(), DateTime.Now); model.Repayment = Utils.StrToDecimal(txtRepayment.Text.Trim(), 0.00M); model.FactRepayment = Utils.StrToDecimal(txtFactRepayment.Text.Trim(), 0.00M); model.FactDispatchCount = Utils.StrToDecimal(txtFactDispatchCount.Text.Trim(), 0.00M); model.FactWeight = Utils.StrToDecimal(txtFactWeight.Text.Trim(), 0.00M); model.ReceivedWeight = Utils.StrToDecimal(txtReceivedWeight.Text.Trim(), 0.00M); model.UnloadingWeight = Utils.StrToDecimal(txtUnloadingWeight.Text.Trim(), 0.00M); model.FactCarriage = Utils.StrToDecimal(txtFactCarriage.Text.Trim(), 0.00M); model.Status = 3; string[] ids = Request.Params.GetValues("OrderId"); string[] unitPrices = Request.Params.GetValues("UnitPrice"); string[] weights = Request.Params.GetValues("Weight"); string[] freights = Request.Params.GetValues("Freight"); string[] paidFreights = Request.Params.GetValues("PaidFreight"); string[] unpaidFreights = Request.Params.GetValues("UnpaidFreight"); string[] costItemNames = Request.Params.GetValues("costItemName"); string[] monies = Request.Params.GetValues("money"); List <Model.Order> item_list = new List <Model.Order>(); BLL.Order orderBLL = new BLL.Order(); Model.Order item; if (ids != null && unitPrices != null && weights != null && freights != null && paidFreights != null && unpaidFreights != null && ids.Length == unitPrices.Length && ids.Length == weights.Length && ids.Length == freights.Length && ids.Length == paidFreights.Length && ids.Length == unpaidFreights.Length && ids.Length > 0) { for (int i = 0; i < ids.Length; i++) { item = orderBLL.GetModel(Utils.StrToInt(ids[i], 0)); if (item != null) { item.UnitPrice = Utils.StrToDecimal(unitPrices[i], 0.00M); item.Weight = Utils.StrToDecimal(weights[i], 0.00M); item.Freight = Utils.StrToDecimal(freights[i], 0.00M); item.PaidFreight = Utils.StrToDecimal(paidFreights[i], 0.00M); item.UnpaidFreight = Utils.StrToDecimal(unpaidFreights[i], 0.00M); item_list.Add(item); } } } List <Model.Consumption> consumption_list = new List <Model.Consumption>(); if (costItemNames != null && monies != null && costItemNames.Length == monies.Length && costItemNames.Length > 0) { for (int i = 0; i < costItemNames.Length; i++) { Model.Consumption consumption = new Model.Consumption(); consumption.Name = costItemNames[i]; consumption.Money = Utils.StrToDecimal(monies[i], 0.00M); consumption.TransportOrderId = _id; consumption_list.Add(consumption); } } if (bll.Update(model, item_list, consumption_list)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "回车报账信息:" + model.Code); //记录日志 result = true; } return(result); }
private bool DoEdit(int _id) { bool result = false; BLL.TransportOrder bll = new BLL.TransportOrder(); Model.TransportOrder model = bll.GetModel(_id); model.FactBackTime = Utils.StrToDateTime(txtFactBackTime.Text.Trim(), DateTime.Now); model.Repayment = Utils.StrToDecimal(txtRepayment.Text.Trim(), 0.00M); model.FactRepayment = Utils.StrToDecimal(txtFactRepayment.Text.Trim(), 0.00M); model.Carriage = Utils.StrToDecimal(txtCarriage.Text.Trim(), 0.00M); model.Status = 2; string[] itemIds = Request.Params.GetValues("transportOrderItemId"); string[] factDispatchCounts = Request.Params.GetValues("factDispatchCount"); string[] factReceivedCounts = Request.Params.GetValues("factReceivedCount"); string[] totalPrices = Request.Params.GetValues("totalPrice"); string[] roundStatus = Request.Params.GetValues("roundStatus"); string[] costItemNames = Request.Params.GetValues("costItemName"); string[] monies = Request.Params.GetValues("money"); List <Model.TransportOrderItem> item_list = new List <Model.TransportOrderItem>(); BLL.TransportOrderItem itemBll = new BLL.TransportOrderItem(); Model.TransportOrderItem item; List <Model.Order> orders = new List <Model.Order>(); BLL.Order orderBll = new BLL.Order(); Model.Order order; for (int i = 0; i < itemIds.Length; i++) { item = itemBll.GetModel(Utils.StrToInt(itemIds[i], 0)); if (item != null) { decimal oldFactDispatchCount = item.FactDispatchCount; decimal newFactDispatchCount = Utils.StrToDecimal(factDispatchCounts[i], 0.00M); order = orderBll.GetModel(item.OrderId); order.DispatchedCount += newFactDispatchCount - oldFactDispatchCount; orders.Add(order); item.FactDispatchCount = newFactDispatchCount; item.FactReceivedCount = Utils.StrToDecimal(factReceivedCounts[i], 0.00M); item.TotalPrice = Utils.StrToDecimal(totalPrices[i], 0.00M); item.RoundStatus = roundStatus[i]; item_list.Add(item); } } List <Model.Consumption> consumption_list = new List <Model.Consumption>(); for (int i = 0; i < costItemNames.Length; i++) { Model.Consumption consumption = new Model.Consumption(); consumption.Name = costItemNames[i]; consumption.Money = Utils.StrToDecimal(monies[i], 0.00M); consumption.TransportOrderId = _id; consumption_list.Add(consumption); } if (bll.Update(model, item_list, consumption_list, orders)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "回车报账信息:" + model.Code); //记录日志 result = true; } return(result); }
/// <summary> /// 得到一个对象实体 /// </summary> public Model.Consumption GetModel(int Id) { StringBuilder strSql = new StringBuilder(); strSql.Append("select Id, Name, TransportOrderId, Money "); strSql.Append(" from mtms_Consumption "); strSql.Append(" where Id=@Id"); SqlParameter[] parameters = { new SqlParameter("@Id", SqlDbType.Int,4) }; parameters[0].Value = Id; Model.Consumption model = new Model.Consumption(); DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["Id"].ToString() != "") { model.Id = int.Parse(ds.Tables[0].Rows[0]["Id"].ToString()); } model.Name = ds.Tables[0].Rows[0]["Name"].ToString(); if (ds.Tables[0].Rows[0]["TransportOrderId"].ToString() != "") { model.TransportOrderId = int.Parse(ds.Tables[0].Rows[0]["TransportOrderId"].ToString()); } if (ds.Tables[0].Rows[0]["Money"].ToString() != "") { model.Money = decimal.Parse(ds.Tables[0].Rows[0]["Money"].ToString()); } return model; } else { return null; } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Model.Consumption model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Model.Consumption model) { return(dal.Add(model)); }
private bool DoEdit(int _id) { bool result = false; BLL.TransportOrder bll = new BLL.TransportOrder(); Model.TransportOrder model = bll.GetModel(_id); model.FactArriveDate = Utils.StrToDateTime(txtFactArriveDate.Text.Trim(), DateTime.Now); model.FactBackTime = Utils.StrToDateTime(txtFactBackTime.Text.Trim(), DateTime.Now); model.Repayment = Utils.StrToDecimal(txtRepayment.Text.Trim(), 0.00M); model.FactRepayment = Utils.StrToDecimal(txtFactRepayment.Text.Trim(), 0.00M); model.FactDispatchCount = Utils.StrToDecimal(txtFactDispatchCount.Text.Trim(), 0.00M); model.FactWeight = Utils.StrToDecimal(txtFactWeight.Text.Trim(), 0.00M); model.ReceivedWeight = Utils.StrToDecimal(txtReceivedWeight.Text.Trim(), 0.00M); model.UnloadingWeight = Utils.StrToDecimal(txtUnloadingWeight.Text.Trim(), 0.00M); model.FactCarriage = Utils.StrToDecimal(txtFactCarriage.Text.Trim(), 0.00M); model.Status = 3; string[] ids = Request.Params.GetValues("OrderId"); string[] unitPrices = Request.Params.GetValues("UnitPrice"); string[] weights = Request.Params.GetValues("Weight"); string[] freights = Request.Params.GetValues("Freight"); string[] paidFreights = Request.Params.GetValues("PaidFreight"); string[] unpaidFreights = Request.Params.GetValues("UnpaidFreight"); string[] costItemNames = Request.Params.GetValues("costItemName"); string[] monies = Request.Params.GetValues("money"); List<Model.Order> item_list = new List<Model.Order>(); BLL.Order orderBLL = new BLL.Order(); Model.Order item; if (ids != null && unitPrices != null && weights != null && freights != null && paidFreights != null && unpaidFreights != null && ids.Length == unitPrices.Length && ids.Length == weights.Length && ids.Length == freights.Length && ids.Length == paidFreights.Length && ids.Length == unpaidFreights.Length && ids.Length > 0) { for (int i = 0; i < ids.Length; i++) { item = orderBLL.GetModel(Utils.StrToInt(ids[i], 0)); if (item != null) { item.UnitPrice = Utils.StrToDecimal(unitPrices[i], 0.00M); item.Weight = Utils.StrToDecimal(weights[i], 0.00M); item.Freight = Utils.StrToDecimal(freights[i], 0.00M); item.PaidFreight = Utils.StrToDecimal(paidFreights[i], 0.00M); item.UnpaidFreight = Utils.StrToDecimal(unpaidFreights[i], 0.00M); item_list.Add(item); } } } List<Model.Consumption> consumption_list = new List<Model.Consumption>(); if (costItemNames != null && monies != null && costItemNames.Length == monies.Length && costItemNames.Length > 0) { for (int i = 0; i < costItemNames.Length; i++) { Model.Consumption consumption = new Model.Consumption(); consumption.Name = costItemNames[i]; consumption.Money = Utils.StrToDecimal(monies[i], 0.00M); consumption.TransportOrderId = _id; consumption_list.Add(consumption); } } if (bll.Update(model, item_list, consumption_list)) { AddAdminLog(DTEnums.ActionEnum.Edit.ToString(), "回车报账信息:" + model.Code); //记录日志 result = true; } return result; }