/// <summary> /// 进货单审批 /// </summary> /// <param name="obj"></param> /// <returns></returns> public ActionResult InStockMgt_Audit(Mes_Stock_InStockApproval obj) { if (obj.InStockID <= 0) { return(Json(new { IsSuccess = false, Message = "请先选择一个进货单!" })); } Mes_Stock_InStock dataObj = MesStockInStockDao.Instance.Find <Mes_Stock_InStock, int>(obj.InStockID); if (dataObj == null) { return(Json(new { IsSuccess = false, Message = "选择的进货单不存在,请刷新后重试!" })); } if (dataObj.AuditStatus == AuditEnum.Yes) { return(Json(new { IsSuccess = false, Message = "选择的进货单已审批,不允许重复审批!" })); } obj.ApproverID = base.CurUser.ID; obj.ApproverName = base.CurUser.UserName; obj.BillNo = dataObj.BillNo; obj.BillType = dataObj.BillType; obj.Creater = base.CurUser.UserId; obj.CreatedTime = DateTime.Now; string message = MesStockInStockDao.Instance.DoAudit(obj); if (!string.IsNullOrEmpty(message)) { return(Json(new { IsSuccess = false, Message = message })); } return(Json(new { IsSuccess = true, Message = "" })); }
public ActionResult InStockItemMgt_Save(Mes_Stock_InStockItem obj) { if (obj.InStockID <= 0) { return(Json(new { IsSuccess = false, Message = "请先选择一个进货单进行操作!" })); } if (string.IsNullOrEmpty(obj.MaterialProNo)) { return(Json(new { IsSuccess = false, Message = "【物料编码】不能为空!" })); } Mes_Stock_InStock main = MesStockInStockDao.Instance.Find <Mes_Stock_InStock, int>(obj.InStockID.Value); if (main == null) { return(Json(new { IsSuccess = false, Message = "选择的进货单信息有误!" })); } Mes_Stock_InStockItem itemObj = null; if (obj.ID > 0) { itemObj = MesStockInStockDao.Instance.Find <Mes_Stock_InStockItem, int>(obj.ID); itemObj.CheckItemStatus = obj.CheckItemStatus; } else { itemObj = new Mes_Stock_InStockItem(); itemObj.AcceptNum = 0; itemObj.BackNum = 0; itemObj.AcceptStatus = YesNoType.No; itemObj.CheckItemStatus = CheckStatus.No; //生成订单行号 itemObj.ResNum = MesStockInStockDao.Instance.GenResNum(main); } if (itemObj == null) { return(Json(new { IsSuccess = false, Message = "进货单明细信息有误,请刷新后重试!" })); } itemObj.InStockID = obj.InStockID; itemObj.BillType = main.BillType; itemObj.BillNo = main.BillNo; itemObj.MaterialProNo = obj.MaterialProNo; itemObj.MaterialCode = obj.MaterialCode; itemObj.Version = obj.Version; itemObj.MaterialSize = obj.MaterialSize; itemObj.Unit = obj.Unit; itemObj.BatchNo = obj.BatchNo; itemObj.AcceptNum = obj.AcceptNum; itemObj.InStockNum = obj.InStockNum; itemObj.AcceptDate = obj.AcceptDate; itemObj.BackNum = obj.BackNum; itemObj.StockID = obj.StockID; int id = MesStockInStockDao.Instance.Save <Mes_Stock_InStockItem>(itemObj); return(Json(new { IsSuccess = true, Message = id.ToString() })); }
/// <summary> /// 生成行号 /// </summary> /// <returns></returns> public int GenResNum(Mes_Stock_InStock obj) { string sql = "SELECT ISNULL(MAX(ResNum),0) FROM Mes_Stock_InStockItem T1 WITH(NOLOCK) WHERE InStockID = {0}"; sql = string.Format(sql, obj.ID); int resNo = this.CurDbSession.FromSql(sql).ToScalar <int>(); return(resNo + 1); }
public ActionResult InStockMgt_FindByPage(Mes_Stock_InStock obj, int page, int rows) { var pager = new PagerBase() { CurrentPageIndex = page, PageSize = rows }; var list = MesStockInStockDao.Instance.FindByPage(obj, ref pager); return(Json(new { total = pager.TotalItemCount, rows = list }, JsonRequestBehavior.AllowGet)); }
public List <Mes_Stock_InStock> FindByPage(Mes_Stock_InStock obj, ref PagerBase pager) { string sql = @"SELECT T1.* FROM Mes_Stock_InStock T1 WHERE 1=1 "; if (TConvertHelper.FormatDBInt(obj.BillType) > 0) { sql += string.Format(" AND T1.BillType = '{0}'", obj.BillType); } if (!string.IsNullOrEmpty(obj.BillNo)) { sql += string.Format(" AND T1.BillNo Like '%{0}%'", obj.BillNo); } if (!string.IsNullOrEmpty(obj.InStockDateStart)) { sql += string.Format(" AND T1.InStockDate >='{0}'", obj.InStockDateStart); } if (!string.IsNullOrEmpty(obj.InStockDateEnd)) { sql += string.Format(" AND T1.InStockDate <'{0}'", TConvertHelper.FormatDBDate(obj.InStockDateEnd).AddDays(1)); } if (obj.AuditStatus > 0) { sql += string.Format(" AND T1.AuditStatus = {0}", obj.AuditStatus); } if (obj.CheckStatus > 0) { sql += string.Format(" AND T1.CheckStatus = {0}", obj.CheckStatus); } if (!string.IsNullOrEmpty(obj.SupplierName)) { sql += string.Format(" AND T1.SupplierName Like '%{0}%'", obj.SupplierName); } if (!string.IsNullOrEmpty(obj.CreatedTimeStart)) { sql += string.Format(" AND T1.CreatedTime >='{0}'", obj.CreatedTimeStart); } if (!string.IsNullOrEmpty(obj.CreatedTimeEnd)) { sql += string.Format(" AND T1.CreatedTime <'{0}'", TConvertHelper.FormatDBDate(obj.CreatedTimeEnd).AddDays(1)); } string orderBy = pager.OrderBy; if (string.IsNullOrEmpty(orderBy)) { orderBy = "CreatedTime DESC"; } string cmdPageSql = string.Format(BaseDao.PageSql, orderBy, sql, pager.StartNo, pager.EndNo); string cmdCountSql = string.Format(BaseDao.CountSql, sql.Substring(sql.ToLower().IndexOf("from", StringComparison.Ordinal))); //查询总记录数 pager.TotalItemCount = this.CurDbSession.FromSql(cmdCountSql).ToScalar <int>(); //返回当前页的记录数 return(this.CurDbSession.FromSql(cmdPageSql).ToList <Mes_Stock_InStock>()); }
public ActionResult InStockMgt_Find(int ID) { if (ID <= 0) { return(Json(new { IsSuccess = false, Message = "选择的记录有误,请刷新后重试!" })); } Mes_Stock_InStock obj = MesStockInStockDao.Instance.Find <Mes_Stock_InStock, int>(ID); if (obj == null) { return(Json(new { IsSuccess = false, Message = "信息不存在,请刷新后重试!" })); } return(Json(new { IsSuccess = true, Message = JsonHelper.SerializeObject(obj) }, JsonRequestBehavior.AllowGet)); }
public List <Mes_Stock_InStock> FindByCond(Mes_Stock_InStock obj) { string sql = @"SELECT T1.* FROM Mes_Stock_InStock T1 WHERE 1=1 "; if (TConvertHelper.FormatDBInt(obj.BillType) > 0) { sql += string.Format(" AND T1.BillType = '{0}'", obj.BillType); } if (!string.IsNullOrEmpty(obj.BillNo)) { sql += string.Format(" AND T1.BillNo Like '%{0}%'", obj.BillNo); } if (!string.IsNullOrEmpty(obj.InStockDateStart)) { sql += string.Format(" AND T1.InStockDate >='{0}'", obj.InStockDateStart); } if (!string.IsNullOrEmpty(obj.InStockDateEnd)) { sql += string.Format(" AND T1.InStockDate <'{0}'", TConvertHelper.FormatDBDate(obj.InStockDateEnd).AddDays(1)); } if (obj.AuditStatus > 0) { sql += string.Format(" AND T1.AuditStatus = {0}", obj.AuditStatus); } if (obj.CheckStatus > 0) { sql += string.Format(" AND T1.CheckStatus = {0}", obj.CheckStatus); } if (!string.IsNullOrEmpty(obj.SupplierName)) { sql += string.Format(" AND T1.SupplierName Like '%{0}%'", obj.SupplierName); } if (!string.IsNullOrEmpty(obj.CreatedTimeStart)) { sql += string.Format(" AND T1.CreatedTime >='{0}'", obj.CreatedTimeStart); } if (!string.IsNullOrEmpty(obj.CreatedTimeEnd)) { sql += string.Format(" AND T1.CreatedTime <'{0}'", TConvertHelper.FormatDBDate(obj.CreatedTimeEnd).AddDays(1)); } sql += " ORDER BY CreatedTime DESC"; //返回当前页的记录数 return(this.CurDbSession.FromSql(sql).ToList <Mes_Stock_InStock>()); }
public ActionResult InStockMgt_Save(Mes_Stock_InStock obj) { if (string.IsNullOrEmpty(obj.BillType)) { return(Json(new { IsSuccess = false, Message = "请选择进货单单别!" })); } if (obj.SupplierID <= 0) { return(Json(new { IsSuccess = false, Message = "请选择供应商!" })); } Mes_Stock_InStock dataObj = null; if (obj.ID > 0) { dataObj = MesStockInStockDao.Instance.Find <Mes_Stock_InStock, int>(obj.ID); } else { dataObj = new Mes_Stock_InStock(); dataObj.AuditStatus = AuditEnum.No; dataObj.Creater = base.CurUser.UserId; dataObj.CreatedTime = DateTime.Now; //生成单号 dataObj.BillNo = MesStockInStockDao.Instance.GenBillNo(); } if (dataObj == null) { return(Json(new { IsSuccess = false, Message = "进货单信息有误,请刷新后重试!" })); } dataObj.BillType = obj.BillType; dataObj.InStockDate = obj.InStockDate; dataObj.SupplierName = obj.SupplierName; dataObj.SupplierID = obj.SupplierID; dataObj.SupBillNo = obj.SupBillNo; dataObj.BillDate = obj.BillDate; dataObj.TotalInStockNum = obj.TotalInStockNum; dataObj.TotalAcceptNum = obj.TotalAcceptNum; dataObj.SourceBillType = obj.SourceBillType; dataObj.SourceBillNo = obj.SourceBillNo; dataObj.CheckStatus = obj.CheckStatus; dataObj.Factory = obj.Factory; int id = MesStockInStockDao.Instance.Save(dataObj); return(Json(new { IsSuccess = true, Message = id.ToString() })); }
/// <summary> /// 导出 /// </summary> /// <param name="obj"></param> /// <returns></returns> public ActionResult ProductInStockMgt_Export(Mes_Stock_InStock obj) { var list = MesStockInStockDao.Instance.FindByCond(obj); BussinessModel bussinessObj = new BussinessModel(); bussinessObj.BusinessType = "InStockMgt"; KeyModel keyObj = null; List <KeyModel> colList = new List <KeyModel>(); keyObj = new KeyModel("单据状态", "Show_AuditStatus"); colList.Add(keyObj); keyObj = new KeyModel("检验状态", "Show_CheckStatus"); colList.Add(keyObj); keyObj = new KeyModel("进货单别", "Show_BillType"); colList.Add(keyObj); keyObj = new KeyModel("进货单号", "BillNo"); colList.Add(keyObj); keyObj = new KeyModel("进货日期", "Show_InStockDate"); colList.Add(keyObj); keyObj = new KeyModel("总进货数量", "TotalInStockNum"); colList.Add(keyObj); keyObj = new KeyModel("总验收数量", "TotalAcceptNum"); colList.Add(keyObj); keyObj = new KeyModel("供应商", "SupplierName"); colList.Add(keyObj); keyObj = new KeyModel("供应商单号", "SupBillNo"); colList.Add(keyObj); keyObj = new KeyModel("销售单别", "Show_SourceBillType"); colList.Add(keyObj); keyObj = new KeyModel("销售单号", "SourceBillNo"); colList.Add(keyObj); keyObj = new KeyModel("创建人", "Creater"); colList.Add(keyObj); keyObj = new KeyModel("创建时间", "Show_CreatedTime"); colList.Add(keyObj); bussinessObj.ColList = colList; string message = SysExportHelper.Export <Mes_Stock_InStock>(ref bussinessObj, list); if (!string.IsNullOrEmpty(message)) { return(Json(new { IsSuccess = false, Message = message })); } return(Json(new { IsSuccess = true, Message = bussinessObj.FileName })); }
public ActionResult InStockMgt_Delete(int ID) { if (ID <= 0) { return(Json(new { IsSuccess = false, Message = "选择的记录有误,请刷新后重试!" })); } Mes_Stock_InStock obj = MesStockInStockDao.Instance.Find <Mes_Stock_InStock, int>(ID); if (obj == null) { return(Json(new { IsSuccess = false, Message = "进货单不存在,请刷新后重试!" })); } if (obj.AuditStatus != AuditEnum.No) { return(Json(new { IsSuccess = false, Message = "只能删除未审核的进货单!" })); } MesStockInStockDao.Instance.DeleteExt(ID); return(Json(new { IsSuccess = true, Message = "" })); }