Esempio n. 1
0
        public ActionResult RatifyApply()
        {
            string     ConsigneeID      = Request.Form["ConsigneeID"].ToString();
            string     DeliveryCode     = Request.Form["DeliveryCode"].ToString();
            DateTime   DeliveryDate     = Convert.ToDateTime(Request.Form["DeliveryDate"]);
            int        ReceivingStoreID = Convert.ToInt32(Request.Form["ReceivingStoreID"]);
            string     Remark           = Request.Form["Remark"].ToString();
            I_Delivery deliveryInfo     = new I_Delivery();

            deliveryInfo.DeliveryCode     = DeliveryCode;
            deliveryInfo.ConsigneeID      = ConsigneeID;
            deliveryInfo.DeliveryTime     = DeliveryDate;
            deliveryInfo.Remark           = Remark;
            deliveryInfo.OperationTime    = DateTime.Now;
            deliveryInfo.OperatorCode     = UserOperateContext.Current.Session_UsrInfo.ID;
            deliveryInfo.ReceivingStoreID = ReceivingStoreID;
            deliveryInfo.DeliveryType     = "MatertalInType-2";

            string sDeliveryDetailInfo = Request.Form["sDeliveryDetailInfo"].ToString();
            List <I_DeliveryDetail> deliveryDetailList = JsonHelper.GetJsonInfoBy <List <I_DeliveryDetail> >(sDeliveryDetailInfo);

            I_Apply applyInfo = new I_Apply();

            applyInfo.ApplyCode      = DeliveryCode;
            applyInfo.ApprovalUserID = UserOperateContext.Current.Session_UsrInfo.ID;
            applyInfo.ApprovalTime   = DeliveryDate;
            applyInfo.ApplyType      = "ApplyType-2";

            List <I_ApplyDetail> applyDetailList = new List <I_ApplyDetail>();

            foreach (I_DeliveryDetail item in deliveryDetailList)
            {
                item.OperatorCode = UserOperateContext.Current.Session_UsrInfo.ID;

                I_ApplyDetail adInfo = new I_ApplyDetail();
                adInfo.ApplyDetailCode = item.DeliveryDetailCode;
                adInfo.ApprovalCounts  = item.DeliveryCounts;

                applyDetailList.Add(adInfo);
            }
            string errorMsg = "";

            if (new I_ApplyBLL().ApproveApplyOperate(applyInfo, applyDetailList, deliveryInfo
                                                     , deliveryDetailList, ref errorMsg))
            {
                return(this.JsonResult(Utility.E_JsonResult.OK, "审批物资申领单成功!", null, null));
            }
            else
            {
                return(this.JsonResult(Utility.E_JsonResult.Error, errorMsg, null, null));
            }
        }
Esempio n. 2
0
        public ActionResult SaveApply()
        {
            string   ApplyUserID      = Request.Form["ApplyUserID"].ToString();
            DateTime ApplyDateTime    = Convert.ToDateTime(Request.Form["ApplyDateTime"]);
            string   ApplyStorage     = Request.Form["ApplyStorage"].ToString();
            string   Remark           = Request.Form["Remark"].ToString();
            string   sApplyDetailInfo = Request.Form["sApplyDetailInfo"].ToString();
            I_Apply  applyInfo        = new I_Apply();

            applyInfo.ApplyCode             = DateTime.Now.AddSeconds(1).ToString("yyyyMMddHHmmss") + ApplyUserID;
            applyInfo.ApplyUserID           = int.Parse(ApplyUserID);
            applyInfo.ApplyReceivingStoreID = int.Parse(ApplyStorage);
            applyInfo.ApplyTime             = ApplyDateTime;
            applyInfo.ApplyType             = "ApplyType-1";
            applyInfo.Remark = Remark;
            List <I_DeliveryDetail> relist = JsonHelper.GetJsonInfoBy <List <I_DeliveryDetail> >(sApplyDetailInfo);
            List <I_ApplyDetail>    adlist = new List <I_ApplyDetail>();
            int ind = 0;

            foreach (I_DeliveryDetail item in relist)
            {
                I_ApplyDetail info = new I_ApplyDetail();
                info.ApplyCode              = applyInfo.ApplyCode;
                info.ApplyDetailCode        = applyInfo.ApplyCode + ind.ToString();
                info.MaterialID             = item.MaterialID;
                info.RealBatchNo            = item.RealBatchNo;
                info.BatchNo                = item.BatchNo;
                info.ApplyTime              = applyInfo.ApplyTime;
                info.ApplyCounts            = item.DeliveryCounts;
                info.ApprovalCounts         = item.DeliveryCounts;
                info.ApplyUserID            = applyInfo.ApplyUserID;
                info.SelfStorageCode        = applyInfo.ApplyReceivingStoreID;
                info.ApplyTargetStorageCode = item.TargetStorageCode;
                info.Remark = item.Remark;
                adlist.Add(info);
                ind++;
            }
            string errorMsg = "";

            if (new I_ApplyBLL().ApplyOperate(applyInfo, adlist, ref errorMsg))
            {
                return(this.JsonResult(Utility.E_JsonResult.OK, "申领物资成功!", null, null));
            }
            else
            {
                return(this.JsonResult(Utility.E_JsonResult.Error, errorMsg, null, null));
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 同意申请
        /// </summary>
        /// <param name="apply"></param>
        /// <param name="applyDetail"></param>
        /// <param name="deliveryInfo"></param>
        /// <param name="deliveryDetailInfos"></param>
        /// <param name="errorMsg"></param>
        /// <returns></returns>
        public bool ApproveApplyOperate(I_Apply apply, List <I_ApplyDetail> applyDetail, I_Delivery deliveryInfo, List <I_DeliveryDetail> deliveryDetailInfos, ref string errorMsg)
        {
            //创建事务
            using (var tran = db.Database.BeginTransaction())
            {
                try
                {
                    //1.0 更新申请表
                    new I_ApplyDAL().Modify(apply, "ApplyType", "ApprovalUserID", "ApprovalTime");
                    foreach (var info in applyDetail)
                    {
                        new I_ApplyDetailDAL().Modify(info, "ApprovalCounts");
                    }

                    //2.0 做出库操作
                    #region 出库操作

                    //1 先插入出库主表
                    dalContext.II_DeliveryDAL.Add(deliveryInfo);

                    foreach (I_DeliveryDetail info in deliveryDetailInfos)
                    {
                        //2. 再插入从表信息
                        dalContext.II_DeliveryDetailDAL.Add(info);

                        //3. 保存剩余流水表
                        dalContext.II_SurplusDAL.SaveDeliverySurplusInfo(info, deliveryInfo.DeliveryType, ref errorMsg);
                    }

                    #endregion

                    tran.Commit(); //提交事务

                    return(true);
                }
                catch (Exception ex)
                {
                    if (tran != null)
                    {
                        tran.Rollback();  //回滚事务
                    }
                    errorMsg = "同意申请操作失败! 操作已取消!~~" + ex.Message;
                    return(false);
                }
            }
        }
Esempio n. 4
0
        public ActionResult RejectApply()
        {
            string  ApprovalId = Request.Form["ApprovalId"].ToString();
            I_Apply model      = new I_Apply();

            model.ApplyCode = ApprovalId;
            model.ApplyType = "ApplyType-3";
            int res = new I_ApplyBLL().Modify(model, "ApplyCode", "ApplyType");

            if (res > 0)
            {
                return(this.JsonResult(Utility.E_JsonResult.OK, "拒绝申领单成功!", null, null));
            }
            else
            {
                return(this.JsonResult(Utility.E_JsonResult.Error, "拒绝申领单失败!", null, null));
            }
        }
Esempio n. 5
0
        /// <summary>
        /// 申请操作
        /// </summary>
        /// <param name="apply">申请主表</param>
        /// <param name="applyDetailInfos">申请从表</param>
        /// <param name="errorMsg">错误信息</param>
        /// <returns></returns>
        public bool ApplyOperate(I_Apply apply, List <I_ApplyDetail> applyDetailInfos, ref string errorMsg)
        {
            //创建事务
            using (var tran = db.Database.BeginTransaction())
            {
                try
                {
                    //1 先插入主表
                    dalContext.II_ApplyDAL.Add(apply);

                    foreach (I_ApplyDetail info in applyDetailInfos)
                    {
                        //2. 再插入从表信息
                        dalContext.II_ApplyDetailDAL.Add(info);
                    }

                    tran.Commit(); //提交事务

                    return(true);
                }
                catch (DbEntityValidationException dbEx)
                {
                    if (tran != null)
                    {
                        tran.Rollback();  //回滚事务
                    }
                    errorMsg = "申请操作失败 失败!  原因:" + dbEx.EntityValidationErrors.FirstOrDefault().ValidationErrors.FirstOrDefault().ErrorMessage;
                    return(false);
                }
                catch (Exception ex)
                {
                    if (tran != null)
                    {
                        tran.Rollback();  //回滚事务
                    }
                    errorMsg = "申请操作失败! 操作已取消!~~" + ex.InnerException.Message;
                    return(false);
                }
            }
        }