private DXInfo.Models.tbStockMain AddStockMain(string cnvcWhCode, string cnvcDeptId, string strOperId, string strOperName, int cnnOperType, DateTime cndBusinessDate) { DXInfo.Models.tbStockMain tbStockMain = new DXInfo.Models.tbStockMain(); tbStockMain.cnvcWhCode = cnvcWhCode; tbStockMain.cnvcDeptId = cnvcDeptId; tbStockMain.cnnOperType = cnnOperType; tbStockMain.cnnSource = 1; tbStockMain.cndCreateDate = DateTime.Now; tbStockMain.cnvcCreaterId = strOperId; tbStockMain.cnvcCreaterName = strOperName; tbStockMain.cndCheckDate = tbStockMain.cndCreateDate; tbStockMain.cnvcCheckerId = tbStockMain.cnvcCreaterId; tbStockMain.cnvcCheckerName = tbStockMain.cnvcCreaterName; tbStockMain.cndBusinessDate = cndBusinessDate; tbStockMain.cnnYear = cndBusinessDate.Year; tbStockMain.cnnMonth = cndBusinessDate.Month; tbStockMain.cnnStatus = (int)StockStatus.Check; tbStockMain.cnvcComments = "月结自动生成下月期初库存"; Uow.tbStockMain.Add(tbStockMain); Uow.Commit(); DXInfo.Models.tbStockMainLog tbStockMainLog = new DXInfo.Models.tbStockMainLog(); ServiceHelper.SetEntity <DXInfo.Models.tbStockMain, DXInfo.Models.tbStockMainLog>(tbStockMain, tbStockMainLog); Uow.tbStockMainLog.Add(tbStockMainLog); return(tbStockMain); }
private string newtbMonthlyBalance(HttpContext context) { try { //using (DXInfo.Models.AMSCM amscm = new DXInfo.Models.AMSCM()) //{ DXInfo.Models.tbMonthlyBalance tbMonthlyBalance = new DXInfo.Models.tbMonthlyBalance(); tbMonthlyBalance.cnnYear = Convert.ToInt32(context.Request.Form["cnnYear"]); tbMonthlyBalance.cnnMonth = Convert.ToInt32(context.Request.Form["cnnMonth"]); tbMonthlyBalance.cnbIsBalance = false; tbMonthlyBalance.cndCreateDate = DateTime.Now; tbMonthlyBalance.cnvcCreater = context.User.Identity.Name; CMSMStruct.LoginStruct ls1 = (CMSMStruct.LoginStruct)context.Session["Login"]; tbMonthlyBalance.cnvcCreaterName = ls1.strOperName; Uow.tbMonthlyBalance.Add(tbMonthlyBalance); DXInfo.Models.tbMonthlyBalanceLog tbMonthlyBalanceLog = new DXInfo.Models.tbMonthlyBalanceLog(); ServiceHelper.SetEntity <DXInfo.Models.tbMonthlyBalance, DXInfo.Models.tbMonthlyBalanceLog>(tbMonthlyBalance, tbMonthlyBalanceLog); Uow.tbMonthlyBalanceLog.Add(tbMonthlyBalanceLog); Uow.Commit(); //} } catch (DbUpdateException dex) { ExceptionPolicy.HandleException(dex, ServiceHelper.ExceptionPolicy); return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, dex.Message))); } return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(true, ""))); }
private AMSCM.Models.tbStockMain AddStockMain(AMSCM.Models.AMSCM amscm, string cnvcWhCode, string cnvcDeptId, string strOperId, string strOperName, int cnnOperType, DateTime cndBusinessDate) { AMSCM.Models.tbStockMain tbStockMain = new AMSCM.Models.tbStockMain(); tbStockMain.cnvcWhCode = cnvcWhCode; tbStockMain.cnvcDeptId = cnvcDeptId; tbStockMain.cnnOperType = cnnOperType; tbStockMain.cnnSource = 1; tbStockMain.cndCreateDate = DateTime.Now; tbStockMain.cnvcCreaterId = strOperId; tbStockMain.cnvcCreaterName = strOperName; tbStockMain.cndCheckDate = tbStockMain.cndCreateDate; tbStockMain.cnvcCheckerId = tbStockMain.cnvcCreaterId; tbStockMain.cnvcCheckerName = tbStockMain.cnvcCreaterName; tbStockMain.cndBusinessDate = cndBusinessDate; tbStockMain.cnnYear = cndBusinessDate.Year; tbStockMain.cnnMonth = cndBusinessDate.Month; tbStockMain.cnnStatus = (int)StockStatus.Check; tbStockMain.cnvcComments = "月结自动生成下月期初库存"; amscm.tbStockMain.Add(tbStockMain); amscm.SaveChanges(); AMSCM.Models.tbStockMainLog tbStockMainLog = new AMSCM.Models.tbStockMainLog(); ServiceHelper.SetEntity <AMSCM.Models.tbStockMain, AMSCM.Models.tbStockMainLog>(tbStockMain, tbStockMainLog); amscm.tbStockMainLog.Add(tbStockMainLog); return(tbStockMain); }
private string balance(HttpContext context) { try { using (TransactionScope transaction = new TransactionScope(TransactionScopeOption.RequiresNew, new TimeSpan(0, 10, 0))) { using (AMSCM.Models.AMSCM amscm = new AMSCM.Models.AMSCM()) { //amscm.Database.Connection.ConnectionTimeout = 600; //更新月结表 int icnnYear = Convert.ToInt32(context.Request.Form["cnnYear"]); int icnnMonth = Convert.ToInt32(context.Request.Form["cnnMonth"]); int icount = (from d in amscm.tbMonthlyBalance where d.cnnYear <= icnnYear && d.cnnMonth < icnnMonth && !d.cnbIsBalance select d).Count(); if (icount > 0) { return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, "请先月结以前月份!"))); } AMSCM.Models.tbMonthlyBalance tbMonthlyBalance = amscm.tbMonthlyBalance.Find(icnnYear, icnnMonth); if (tbMonthlyBalance.cnbIsBalance) { return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, "已月结!"))); } tbMonthlyBalance.cnbIsBalance = true; string strOperId = context.User.Identity.Name; CMSMStruct.LoginStruct ls1 = (CMSMStruct.LoginStruct)context.Session["Login"]; string strOperName = ls1.strOperName; tbMonthlyBalance.cndBalanceDate = DateTime.Now; tbMonthlyBalance.cnvcBalancer = strOperId; tbMonthlyBalance.cnvcBalancerName = strOperName; AMSCM.Models.tbMonthlyBalanceLog tbMonthlyBalanceLog = new AMSCM.Models.tbMonthlyBalanceLog(); ServiceHelper.SetEntity <AMSCM.Models.tbMonthlyBalance, AMSCM.Models.tbMonthlyBalanceLog>(tbMonthlyBalance, tbMonthlyBalanceLog); amscm.tbMonthlyBalanceLog.Add(tbMonthlyBalanceLog); //更新盘点和领料单的成本 Compute(amscm, tbMonthlyBalance, strOperId, strOperName); amscm.SaveChanges(); transaction.Complete(); } } } catch (TimeoutException tex) { ExceptionPolicy.HandleException(tex, ServiceHelper.ExceptionPolicy); return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, tex.Message))); } catch (DbUpdateException dex) { ExceptionPolicy.HandleException(dex, ServiceHelper.ExceptionPolicy); return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, dex.Message))); } return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(true, ""))); }
private string balance(HttpContext context) { try { //using (DXInfo.Models.AMSCM amscm = new DXInfo.Models.AMSCM()) //{ using (TransactionScope transaction = new TransactionScope()) { //更新月结表 int icnnYear = Convert.ToInt32(context.Request.Form["cnnYear"]); int icnnMonth = Convert.ToInt32(context.Request.Form["cnnMonth"]); int icount = (from d in Uow.tbMonthlyBalance.GetAll() where d.cnnYear <= icnnYear && d.cnnMonth < icnnMonth && !d.cnbIsBalance select d).Count(); if (icount > 0) { return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, "请先月结以前月份!"))); } DXInfo.Models.tbMonthlyBalance tbMonthlyBalance = Uow.tbMonthlyBalance.GetById(g => g.cnnYear == icnnYear && g.cnnMonth == icnnMonth); if (tbMonthlyBalance.cnbIsBalance) { return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, "已月结!"))); } tbMonthlyBalance.cnbIsBalance = true; string strOperId = context.User.Identity.Name; CMSMStruct.LoginStruct ls1 = (CMSMStruct.LoginStruct)context.Session["Login"]; string strOperName = ls1.strOperName; tbMonthlyBalance.cndBalanceDate = DateTime.Now; tbMonthlyBalance.cnvcBalancer = strOperId; tbMonthlyBalance.cnvcBalancerName = strOperName; DXInfo.Models.tbMonthlyBalanceLog tbMonthlyBalanceLog = new DXInfo.Models.tbMonthlyBalanceLog(); ServiceHelper.SetEntity <DXInfo.Models.tbMonthlyBalance, DXInfo.Models.tbMonthlyBalanceLog>(tbMonthlyBalance, tbMonthlyBalanceLog); Uow.tbMonthlyBalanceLog.Add(tbMonthlyBalanceLog); //更新盘点和领料单的成本 Compute(tbMonthlyBalance, strOperId, strOperName); Uow.Commit(); transaction.Complete(); } //} } catch (DbUpdateException dex) { ExceptionPolicy.HandleException(dex, ServiceHelper.ExceptionPolicy); return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, dex.Message))); } return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(true, ""))); }
public static void AddStockDetal(IAMSCMUow uow, DXInfo.Models.tbStockMain tbStockMain, string cnvcInvCode , string cnvcComUnitCode, decimal cnnQuantity, string cnvcMainComUnitCode, decimal cnnMainQuantity, decimal cnnPrice, decimal cnnAmount) { DXInfo.Models.tbStockDetail tbStockDetail = new DXInfo.Models.tbStockDetail(); tbStockDetail.cnnMainId = tbStockMain.cnnMainId; tbStockDetail.cnvcInvCode = cnvcInvCode; tbStockDetail.cnvcComUnitCode = cnvcComUnitCode; tbStockDetail.cnnQuantity = cnnQuantity; tbStockDetail.cnvcMainComUnitCode = cnvcMainComUnitCode; tbStockDetail.cnnMainQuantity = cnnMainQuantity; tbStockDetail.cnnPrice = cnnPrice; tbStockDetail.cnnAmount = cnnAmount; tbStockDetail.cndOperDate = tbStockMain.cndCreateDate; tbStockDetail.cnvcOper = tbStockMain.cnvcCreaterId; tbStockDetail.cnvcOperName = tbStockMain.cnvcCreaterName; uow.tbStockDetail.Add(tbStockDetail); uow.Commit(); DXInfo.Models.tbStockDetailLog tbStockDetailLog = new DXInfo.Models.tbStockDetailLog(); ServiceHelper.SetEntity <DXInfo.Models.tbStockDetail, DXInfo.Models.tbStockDetailLog>(tbStockDetail, tbStockDetailLog); uow.tbStockDetailLog.Add(tbStockDetailLog); }
public static void AddStockDetal(AMSCM.Models.AMSCM amscm, AMSCM.Models.tbStockMain tbStockMain, string cnvcInvCode , string cnvcComUnitCode, decimal cnnQuantity, string cnvcMainComUnitCode, decimal cnnMainQuantity, decimal cnnPrice, decimal cnnAmount) { AMSCM.Models.tbStockDetail tbStockDetail = new AMSCM.Models.tbStockDetail(); tbStockDetail.cnnMainId = tbStockMain.cnnMainId; tbStockDetail.cnvcInvCode = cnvcInvCode; tbStockDetail.cnvcComUnitCode = cnvcComUnitCode; tbStockDetail.cnnQuantity = cnnQuantity; tbStockDetail.cnvcMainComUnitCode = cnvcMainComUnitCode; tbStockDetail.cnnMainQuantity = cnnMainQuantity; tbStockDetail.cnnPrice = cnnPrice; tbStockDetail.cnnAmount = cnnAmount; tbStockDetail.cndOperDate = tbStockMain.cndCreateDate; tbStockDetail.cnvcOper = tbStockMain.cnvcCreaterId; tbStockDetail.cnvcOperName = tbStockMain.cnvcCreaterName; amscm.tbStockDetail.Add(tbStockDetail); amscm.SaveChanges(); AMSCM.Models.tbStockDetailLog tbStockDetailLog = new AMSCM.Models.tbStockDetailLog(); ServiceHelper.SetEntity <AMSCM.Models.tbStockDetail, AMSCM.Models.tbStockDetailLog>(tbStockDetail, tbStockDetailLog); amscm.tbStockDetailLog.Add(tbStockDetailLog); }
private string cancelBalance(HttpContext context) { try { //using (DXInfo.Models.AMSCM amscm = new DXInfo.Models.AMSCM()) //{ using (TransactionScope transaction = new TransactionScope()) { int icnnYear = Convert.ToInt32(context.Request.Form["cnnYear"]); int icnnMonth = Convert.ToInt32(context.Request.Form["cnnMonth"]); int icount = (from d in Uow.tbMonthlyBalance.GetAll() where d.cnnYear >= icnnYear && d.cnnMonth > icnnMonth && d.cnbIsBalance select d).Count(); if (icount > 0) { return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, "请先取消以前月份月结!"))); } DXInfo.Models.tbMonthlyBalance tbMonthlyBalance = Uow.tbMonthlyBalance.GetById(g => g.cnnYear == icnnYear && g.cnnMonth == icnnMonth); if (!tbMonthlyBalance.cnbIsBalance) { return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, "未月结!"))); } tbMonthlyBalance.cnbIsBalance = false; tbMonthlyBalance.cndModifyDate = DateTime.Now; tbMonthlyBalance.cnvcModifier = context.User.Identity.Name; CMSMStruct.LoginStruct ls1 = (CMSMStruct.LoginStruct)context.Session["Login"]; tbMonthlyBalance.cnvcModifierName = ls1.strOperName; tbMonthlyBalance.cndBalanceDate = null; tbMonthlyBalance.cnvcBalancer = string.Empty; tbMonthlyBalance.cnvcBalancerName = string.Empty; Uow.Commit(); DXInfo.Models.tbMonthlyBalanceLog tbMonthlyBalanceLog = new DXInfo.Models.tbMonthlyBalanceLog(); ServiceHelper.SetEntity <DXInfo.Models.tbMonthlyBalance, DXInfo.Models.tbMonthlyBalanceLog>(tbMonthlyBalance, tbMonthlyBalanceLog); Uow.tbMonthlyBalanceLog.Add(tbMonthlyBalanceLog); int icnnCheckStatus = (int)StockStatus.Check; List <long> lcnnDetailId = (from main in Uow.tbStockMain.GetAll() join d in Uow.tbStockDetail.GetAll() on main.cnnMainId equals d.cnnMainId into md from detail in md.DefaultIfEmpty() where main.cnnYear == tbMonthlyBalance.cnnYear && main.cnnMonth == tbMonthlyBalance.cnnMonth && main.cnnStatus == icnnCheckStatus && main.cnnOperType != 0 && main.cnnOperType != 1 orderby main.cnnMainId select detail.cnnDetailId).Distinct().ToList(); foreach (long cnnDetailId in lcnnDetailId) { DXInfo.Models.tbStockDetail tbStockDetail = Uow.tbStockDetail.GetById(g => g.cnnDetailId == cnnDetailId); tbStockDetail.cnnPrice = 0; tbStockDetail.cnnAmount = 0; DXInfo.Models.tbStockDetailLog tbStockDetailLog = new DXInfo.Models.tbStockDetailLog(); ServiceHelper.SetEntity <DXInfo.Models.tbStockDetail, DXInfo.Models.tbStockDetailLog>(tbStockDetail, tbStockDetailLog); Uow.tbStockDetailLog.Add(tbStockDetailLog); } int inextcnnYear = icnnYear; int inextcnnMonth = icnnMonth + 1; if (icnnMonth == 12) { inextcnnYear += 1; inextcnnMonth = 1; } var q = (from main in Uow.tbStockMain.GetAll() join d in Uow.tbStockDetail.GetAll() on main.cnnMainId equals d.cnnMainId into md from detail in md.DefaultIfEmpty() where main.cnnYear == inextcnnYear && main.cnnMonth == inextcnnMonth && main.cnnStatus == icnnCheckStatus && main.cnnSource == 1 orderby main.cnnMainId select new { detail.cnnMainId, detail.cnnDetailId }).Distinct().ToList(); var q1 = (from d in q select d.cnnMainId).Distinct().ToList(); var q2 = (from d in q select d.cnnDetailId).Distinct().ToList(); if (q1.Count > 0) { foreach (long cnnMainId in q1) { DXInfo.Models.tbStockMain tbStockMain = Uow.tbStockMain.GetById(g => g.cnnMainId == cnnMainId); tbStockMain.cnnStatus = (int)StockStatus.Delete; Uow.tbStockMain.Delete(tbStockMain); DXInfo.Models.tbStockMainLog tbStockMainLog = new DXInfo.Models.tbStockMainLog(); ServiceHelper.SetEntity <DXInfo.Models.tbStockMain, DXInfo.Models.tbStockMainLog>(tbStockMain, tbStockMainLog); Uow.tbStockMainLog.Add(tbStockMainLog); } } if (q2.Count > 0) { foreach (long cnnDetailId in q2) { DXInfo.Models.tbStockDetail tbStockDetail = Uow.tbStockDetail.GetById(g => g.cnnDetailId == cnnDetailId); Uow.tbStockDetail.Delete(tbStockDetail); DXInfo.Models.tbStockDetailLog tbStockDetailLog = new DXInfo.Models.tbStockDetailLog(); ServiceHelper.SetEntity <DXInfo.Models.tbStockDetail, DXInfo.Models.tbStockDetailLog>(tbStockDetail, tbStockDetailLog); Uow.tbStockDetailLog.Add(tbStockDetailLog); } } Uow.Commit(); transaction.Complete(); } //} } catch (DbUpdateException dex) { ExceptionPolicy.HandleException(dex, ServiceHelper.ExceptionPolicy); return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(false, dex.Message))); } return(ServiceHelper.JsonSerializer <JEasyUIResult>(new JEasyUIResult(true, ""))); }