public static string Edit(string KeyID, string type, string remark) { remark = Common.NoHTML(remark); Common.ResultMessage Msg = new Common.ResultMessage(); if (type == "0") { Hi.BLL.DIS_Order OrderBll = new Hi.BLL.DIS_Order(); int oID = Common.DesDecrypt(KeyID, Common.EncryptKey).ToInt(0); Hi.Model.DIS_Order OrderModel = OrderBll.GetModel(oID); if (OrderModel != null) { OrderModel.Remark = Common.NoHTML(remark); OrderModel.ts = DateTime.Now; if (OrderBll.Update(OrderModel)) { Msg.result = true; Msg.code = OrderModel.ts.ToString("yyyy-MM-dd HH:mm"); } } else { Msg.code = "未查找到数据"; } } else if (type == "1") { Hi.BLL.DIS_OrderDetail OrderBllDetail = new Hi.BLL.DIS_OrderDetail(); Hi.Model.DIS_OrderDetail OrderModelDetail = OrderBllDetail.GetModel(KeyID.ToInt(0)); if (OrderModelDetail != null) { OrderModelDetail.Remark = Common.NoHTML(remark); OrderModelDetail.ts = DateTime.Now; if (OrderBllDetail.Update(OrderModelDetail)) { Msg.result = true; } } } else { Msg.result = true; } return(new JavaScriptSerializer().Serialize(Msg)); }
/// <summary> /// 修改订单 /// </summary> /// <param name="OrderInfoModel"></param> /// <param name="OrderDetailList"></param> /// <returns></returns> public static int UpdateOrder(DateTime dts, Hi.Model.DIS_Order OrderInfoModel, Hi.Model.DIS_OrderExt OrderExt, List <Hi.Model.DIS_OrderDetail> OrderDetailList, string delOrderD) { //判断订单时间 if (new Hi.BLL.DIS_Order().Getts("Dis_Order", OrderInfoModel.ID, dts) == 0) { return(-1); } int OrderId = 0; //返回修改库存的sql System.Text.StringBuilder sqlInven = new System.Text.StringBuilder(); int IsInve = OrderInfoType.rdoOrderAudit("商品是否启用库存", OrderInfoModel.CompID).ToInt(0); if (IsInve == 0) { //修改商品库存,先返还订单明细删除的商品库存 sqlInven.AppendFormat(new Hi.BLL.DIS_Order().GetSqlInventory(delOrderD, OrderDetailList)); } //SqlConnection con = new SqlConnection(LocalSqlServer); //con.Open(); //System.Data.IsolationLevel.RepeatableRead SqlTransaction sqlTrans = DBUtility.SqlHelper.CreateStoreTranSaction(); //可以做循环 try { //private object thislock = OrderInfoModel.ID as object; //lock (thislock) //{ OrderId = OrderBll.UpdateOrder(sqlTrans.Connection, OrderInfoModel, sqlTrans); if (OrderDetailList.Count <= 0) { OrderId = 0; sqlTrans.Rollback(); } else { if (OrderExt != null) { //修改订单扩展表 if (!OrderExtBll.Update(sqlTrans.Connection, OrderExt, sqlTrans)) { OrderId = 0; sqlTrans.Rollback(); } } if (!delOrderD.Equals("")) { //修改时 删除商品后 清除在数据库中存在的该商品 if (OrderDetailBll.GetDel(delOrderD, sqlTrans.Connection, sqlTrans) < 0) { OrderId = 0; sqlTrans.Rollback(); } } foreach (Hi.Model.DIS_OrderDetail item in OrderDetailList) { Hi.Model.DIS_OrderDetail OrderDeModel = OrderDetailBll.GetModel(item.ID); int count = 0; if (OrderDeModel != null) { if (IsInve == 0) { //修改订单明细时,先返还商品库存 sqlInven.AppendFormat("update BD_GoodsInfo set Inventory+={0} where ID={1};", OrderDeModel.GoodsNum + Convert.ToDecimal(OrderDeModel.ProNum), OrderDeModel.GoodsinfoID); } item.OrderID = OrderInfoModel.ID; //修改订单时,订单明细里存在该商品 修改商品信息 count = OrderDetailBll.UpdateOrderDetail(sqlTrans.Connection, item, sqlTrans); if (count == 0) { OrderId = 0; sqlTrans.Rollback(); } } else { //修改订单时,订单明细里不存在该商品新增商品信息 item.OrderID = OrderInfoModel.ID; count = OrderDetailBll.AddOrderDetail(sqlTrans.Connection, item, sqlTrans); if (count == 0) { OrderId = 0; sqlTrans.Rollback(); } } } if (IsInve == 0) { //修改商品库存,先返还订单明细删除的商品库存 //sqlInven.AppendFormat(new Hi.BLL.DIS_Order().GetSqlInventory(delOrderD, OrderDetailList)); if (new Hi.BLL.DIS_OrderDetail().GetUpdateInventory(sqlInven.ToString(), sqlTrans.Connection, sqlTrans) <= 0) { OrderId = 0; sqlTrans.Rollback(); } } if (OrderInfoType.rdoOrderAudit("订单支付返利是否启用", OrderInfoModel.CompID) == "1") { //订单支付返利启用 if (bate.TransEditRebate(OrderInfoModel.DisID, OrderInfoModel.bateAmount, OrderInfoModel.ID, OrderInfoModel.CreateUserID, sqlTrans)) { sqlTrans.Commit(); return(OrderId); } } sqlTrans.Commit(); } //} } catch { OrderId = 0; sqlTrans.Rollback(); } finally { } return(OrderId); }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(Hi.Model.DIS_OrderDetail model) { return(dal.Update(model)); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(Hi.Model.DIS_OrderDetail model) { return(dal.Add(model)); }