/// <summary> /// 更新信息 /// </summary> /// <param name="purch_id"></param> /// <param name="express_id"></param> /// <param name="express_code"></param> /// <param name="express_name"></param> /// <param name="OrderCode"></param> /// <returns></returns> public MaterialReceiptResult Modify(Int64?purch_id, Int64?express_id, string express_code, string express_name, string OrderCode) { bool rstNum = false; MaterialReceiptResult result = new MaterialReceiptResult(); using (var db = SugarDao.GetInstance(LoginUser.GetConstr())) { db.BeginTran(); var list = db.Queryable <busi_purchase>().Where(s => s.del_flag).InSingle(purch_id.Value); if (list == null) { db.RollbackTran(); result.success = false; result.Msg = "无效的采购信息,操作失败!"; return(result); } rstNum = db.Update <busi_purchase>(new { purch_status = 3, express_id = express_id, express_code = express_code, express_name = express_name, OrderCode = OrderCode }, a => a.purch_id == purch_id && a.purch_status == 3); if (rstNum) { db.CommitTran(); result.success = true; result.Msg = "操作成功"; return(result); } else { db.RollbackTran(); result.success = false; result.Msg = "操作失败"; return(result); } } }
public ActionResult Getpage(string pagenum, string onepagecount, string express_code) { MaterialReceiptResult com = new MaterialReceiptResult(); InternationalQuiryResult coms = new InternationalQuiryResult(); if (!Regex.IsMatch(pagenum, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(pagenum)) { com.Msg = "页数不正确"; com.success = false; return(Json(com)); } if (!Regex.IsMatch(onepagecount, @"(?i)^[0-9a-z\u4e00-\u9fa5]+$") && !string.IsNullOrEmpty(onepagecount)) { com.Msg = "每页数量不正确"; com.success = false; return(Json(com)); } int totil = 0; int totilpage = 0; string exmsg = string.Empty; List <MaterialReceiptModel> mylist = _service.GetMaterialReceiptList(Convert.ToInt32(pagenum), Convert.ToInt32(onepagecount), out totil, out totilpage, out exmsg, express_code); coms = _internationalQuiry.GetExpressList(); if (!string.IsNullOrEmpty(exmsg)) { com.Msg = exmsg; com.success = false; return(Json(com)); } else { MaterialReceiptViewModel mylistview = new MaterialReceiptViewModel(); mylistview.supplist = mylist; mylistview.totil = totil.ToString(); mylistview.totilcount = totilpage.ToString(); if (coms.success) { mylistview.express_info = coms.Msg; } else { mylistview.express_info = null; } com.DataResult = mylistview; com.success = true; return(Json(com)); } }
public ActionResult Save1(busi_purchase model, List <MaterialReceiptModelE> lists) { MaterialReceiptResult com = new MaterialReceiptResult(); try { return(Json(com)); } catch (Exception ex) { com.Msg = ex.ToString(); com.success = false; return(Json(com)); } }
public ActionResult Save(busi_purchase model, List <MaterialReceiptSaveModel> lists, int?purch_type) { MaterialReceiptResult com = new MaterialReceiptResult(); try { com = _service.Save(model, lists, purch_type); return(Json(com)); } catch (Exception ex) { com.Msg = ex.ToString(); com.success = false; return(Json(com)); } }
public ActionResult GetpageE(Int64?purch_id) { MaterialReceiptResult com = new MaterialReceiptResult(); string exmsg = string.Empty; List <MaterialReceiptModelE> mylist = _service.GetMaterialReceiptEList(out exmsg, purch_id.Value); if (!string.IsNullOrEmpty(exmsg)) { com.Msg = exmsg; com.success = false; return(Json(com)); } else { MaterialReceiptViewModelE mylistview = new MaterialReceiptViewModelE(); mylistview.supplist = mylist; com.DataResult = mylistview; com.success = true; return(Json(com)); } }
public ActionResult Modify(Int64?purch_id, Int64?express_id, string express_code, string express_name, string OrderCode) { MaterialReceiptResult com = new MaterialReceiptResult(); if (purch_id == 0) { com.Msg = "参数错误!"; com.success = false; return(Json(com)); } if (express_id == 0 || string.IsNullOrEmpty(express_name)) { com.Msg = "请选择快递公司!"; com.success = false; return(Json(com)); } if (string.IsNullOrWhiteSpace(express_code)) { com.Msg = "请填写快递单号!"; com.success = false; return(Json(com)); } if (string.IsNullOrWhiteSpace(OrderCode)) { com.Msg = "请填写淘宝订单号!"; com.success = false; return(Json(com)); } try { com = _service.Modify(purch_id, express_id, express_code, express_name, OrderCode); return(Json(com)); } catch (Exception ex) { com.Msg = ex.ToString(); com.success = false; return(Json(com)); } }
/// <summary> /// 采购收货 /// </summary> /// <param name="model"></param> /// <param name="lists"></param> /// <param name="purch_type"></param> /// <returns></returns> public MaterialReceiptResult Save(busi_purchase model, List <MaterialReceiptSaveModel> lists, int?purch_type) { bool rstNum = false; bool rstNums = false; bool rstNumss = false; MaterialReceiptResult result = new MaterialReceiptResult(); using (var db = SugarDao.GetInstance(LoginUser.GetConstr())) { try { db.BeginTran(); #region 判断 if (model == null) { result.success = false; result.Msg = "请填写信息!"; return(result); } if (model.purch_id == 0) { result.success = false; result.Msg = "参数错误!"; return(result); } if (!purch_type.HasValue || purch_type < 0) { result.success = false; result.Msg = "参数错误!"; return(result); } #endregion int suc = 0; var list = db.Queryable <busi_purchase>().Where(s => s.del_flag).InSingle(model.purch_id); if (list == null) { result.success = false; result.Msg = "不存在的采购信息"; return(result); } if (list.purch_status == 4) { result.success = false; result.Msg = "该单号已收货,请勿重复操作!"; return(result); } list.edit_time = DateTime.Now; list.purch_status = 4; list.edit_user_id = 0; rstNum = db.Update <busi_purchase>(list); if (rstNum) { rstNums = db.Update <busi_purchasedetail>(new { purch_status = 4 }, a => a.purch_id == model.purch_id && a.purch_status == 3); if (lists.Count > 0) { if (purch_type == 1) { foreach (var item in lists) { var stock = db.Queryable <base_wh_stock>().Where(s => s.del_flag && s.code_id == item.code_id && s.prod_id == item.prod_id && s.location_id == 1 && s.wh_id == 1).FirstOrDefault(); if (stock != null) { Decimal oldwh_stock = stock.stock_qty; Decimal newwh_stock = oldwh_stock + item.prod_num; rstNumss = db.Update <base_wh_stock>(new { stock_qty = newwh_stock }, s => s.stock_id == stock.stock_id); if (rstNumss) { suc += 1; } } else { var wh_warehouse = db.Queryable <base_wh_warehouse>().Where(s => s.del_flag).InSingle(1); if (wh_warehouse != null) { base_wh_stock wh_stock = new base_wh_stock(); wh_stock.prod_id = item.prod_id; wh_stock.occupied_qty = 0; wh_stock.pallet_id = 0; wh_stock.purchase_price = 0; wh_stock.remark = "采购收货"; wh_stock.reserve_qty = 0; wh_stock.service_life = ""; wh_stock.stock_barcode = ""; wh_stock.stock_class = 3; wh_stock.stock_code = "1"; wh_stock.stock_qty = item.prod_num; wh_stock.stock_status = true; wh_stock.retrieval_time = DateTime.Now; wh_stock.storage_time = DateTime.Now; wh_stock.supplier_id = item.supp_id; wh_stock.using_state = 1; wh_stock.wh_id = 1; wh_stock.location_id = 1; wh_stock.locking_qty = 0; wh_stock.area_id = 0; wh_stock.asset_class_id = 0; wh_stock.code_id = item.code_id; wh_stock.consignor_id = 0; wh_stock.create_time = DateTime.Now; wh_stock.create_user_id = LoginUser.Current.user_id; wh_stock.del_flag = true; wh_stock.del_user_id = 0; wh_stock.edit_user_id = 0; wh_stock.del_time = DateTime.Now; wh_stock.edit_time = DateTime.Now; wh_stock.stock_id = Guid.NewGuid(); var id = db.Insert <base_wh_stock>(wh_stock); if (id.ObjToBool()) { suc += 1; } } else { db.RollbackTran(); result.success = false; result.Msg = "操作失败! 请先添加<span style=\"color:red;\">金华仓</span>!"; return(result); } } } } else if (purch_type == 2) { foreach (var item in lists) { var stock = db.Queryable <base_wh_stock>().Where(s => s.del_flag && s.code_id == item.code_id && s.prod_id == item.prod_id && s.location_id != 1 && s.wh_id == 1).FirstOrDefault(); if (stock != null) { Decimal oldwh_stock = stock.stock_qty; Decimal newwh_stock = oldwh_stock + item.prod_num; if (newwh_stock >= 0) { rstNumss = db.Update <base_wh_stock>(new { stock_qty = newwh_stock }, s => s.stock_id == stock.stock_id); if (rstNumss) { suc += 1; } } } else { var location = db.Queryable <base_location>().Where(s => s.del_flag && s.wh_id == 1 && s.locat_type == 2).FirstOrDefault(); if (location != null) { base_wh_stock wh_stock = new base_wh_stock(); wh_stock.prod_id = item.prod_id; wh_stock.occupied_qty = 0; wh_stock.pallet_id = 0; wh_stock.purchase_price = 0; wh_stock.remark = "库存采购"; wh_stock.reserve_qty = 0; wh_stock.service_life = ""; wh_stock.stock_barcode = ""; wh_stock.stock_class = 3; wh_stock.stock_code = "1"; wh_stock.stock_qty = item.prod_num; wh_stock.stock_status = true; wh_stock.retrieval_time = DateTime.Now; wh_stock.storage_time = DateTime.Now; wh_stock.supplier_id = item.supp_id; wh_stock.using_state = 1; wh_stock.wh_id = 1; wh_stock.location_id = location.locat_id; wh_stock.locking_qty = 0; wh_stock.area_id = 0; wh_stock.asset_class_id = 0; wh_stock.code_id = item.code_id; wh_stock.consignor_id = 0; wh_stock.create_time = DateTime.Now; wh_stock.create_user_id = LoginUser.Current.user_id; wh_stock.del_flag = true; wh_stock.del_user_id = 0; wh_stock.edit_user_id = 0; wh_stock.del_time = DateTime.Now; wh_stock.edit_time = DateTime.Now; wh_stock.stock_id = Guid.NewGuid(); var id = db.Insert <base_wh_stock>(wh_stock); if (id.ObjToBool()) { suc += 1; } } else { db.RollbackTran(); result.success = false; result.Msg = "<span style=\"color:red;\">金华仓</span>暂无库位,请先添加<span style=\"color:red;\">金华仓</span>库位,在进行操作!"; return(result); } } } } } } if (suc == lists.Count) { db.CommitTran(); result.success = true; // result.URL = "/MaterialReceipt/IndexE?id=" + model.purch_id + ""; result.Msg = "操作成功"; return(result); } else { db.RollbackTran(); result.success = false; result.Msg = "操作失败"; return(result); } } catch (Exception) { db.RollbackTran(); throw; } } }