コード例 #1
0
        //审核
        public JsonResult ManualExpressReportCheck(T_ManualExpress model, string status, string Memo)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                int             ID           = model.ID;
                T_ManualExpress Invoicemodel = db.T_ManualExpress.SingleOrDefault(a => a.ID == ID && a.Isdelete == 0);
                if (Invoicemodel == null)
                {
                    return(Json("数据可能被删除", JsonRequestBehavior.AllowGet));
                }

                T_ManualExpressAppRove modelApprove = db.T_ManualExpressAppRove.FirstOrDefault(a => a.Oid == ID && a.ApproveTime == null);
                string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value);

                string result = "";
                modelApprove.ApproveName = Nickname;
                modelApprove.Memo        = Memo;
                modelApprove.ApproveTime = DateTime.Now;
                modelApprove.Status      = int.Parse(status);
                db.Entry <T_ManualExpressAppRove>(modelApprove).State = System.Data.Entity.EntityState.Modified;
                int i = db.SaveChanges();
                if (i > 0)
                {
                    if (status == "1")
                    {
                        T_ManualExpressAppRove newApprove = new T_ManualExpressAppRove();
                        int step = int.Parse(Invoicemodel.Step.ToString());
                        step++;
                        IQueryable <T_ManualExpressConfig> config = db.T_ManualExpressConfig.AsQueryable();
                        int stepLength = config.Count();//总共步骤
                        if (step < stepLength)
                        {
                            Invoicemodel.Status = 0;
                            T_ManualExpressConfig stepMod = db.T_ManualExpressConfig.SingleOrDefault(a => a.Step == step);
                            string nextName = stepMod.Name;
                            newApprove.Memo   = "";
                            newApprove.Oid    = ID;
                            newApprove.Status = -1;
                            newApprove.Step   = step.ToString();
                            if (nextName != null)
                            {
                                newApprove.ApproveName  = nextName;
                                newApprove.ApproveDName = stepMod.Type;
                            }
                            else
                            {
                                newApprove.ApproveName  = stepMod.Type;
                                newApprove.ApproveDName = stepMod.Type;
                            }
                            db.T_ManualExpressAppRove.Add(newApprove);
                            db.SaveChanges();
                        }
                        else
                        {
                            Invoicemodel.Status = int.Parse(status);
                        }
                        Invoicemodel.Step = step;
                        db.Entry <T_ManualExpress>(Invoicemodel).State = System.Data.Entity.EntityState.Modified;
                        int j = db.SaveChanges();
                        ModularByZP();
                        sc.Complete();
                        if (j > 0)
                        {
                            result = "保存成功";
                        }
                        else
                        {
                            result = "保存失败";
                        }
                    }
                    else
                    {
                        //不同意
                        Invoicemodel.Step   = 0;
                        Invoicemodel.Status = 2;
                        db.Entry <T_ManualExpress>(Invoicemodel).State = System.Data.Entity.EntityState.Modified;
                        int j = db.SaveChanges();
                        //审核流程结束 申请人编辑后插入下一条记录
                        sc.Complete();
                        if (j > 0)
                        {
                            result = "保存成功";
                        }
                        else
                        {
                            result = "保存失败";
                        }
                    }
                }
                else
                {
                    result = "保存失败";
                }


                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
コード例 #2
0
        public JsonResult ManualExpressAdd(T_ManualExpress model, string jsonStr, string p_c_a, string Expense)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                try
                {
                    string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value);
                    model.ApplyName       = Nickname;
                    model.ApplyDate       = DateTime.Now;
                    model.Status          = -1;
                    model.Step            = 0;
                    model.Isdelete        = 0;
                    model.DetailedAddress = p_c_a;
                    db.T_ManualExpress.Add(model);
                    int i = db.SaveChanges();
                    if (i > 0)
                    {
                        List <T_ManualExpressDetail> details = App_Code.Com.Deserialize <T_ManualExpressDetail>(jsonStr);



                        foreach (var item in details)
                        {
                            string express = item.express;
                            // List<T_ManualExpress> Dmodel = db.T_ManualExpress.Where(a => a.Isdelete !=1).ToList();
                            List <T_ManualExpressDetail> Dmodel = db.T_ManualExpressDetail.Where(a => a.express == express).ToList();
                            if (Dmodel.Count > 0)
                            {
                                int[] PIDs = Dmodel.Select(a => a.Oid).ToArray();
                                List <T_ManualExpress> list = db.T_ManualExpress.Where(a => PIDs.Contains(a.ID) && a.Isdelete == 0).ToList();
                                if (list.Count > 0)
                                {
                                    return(Json(new { State = "cuowu" }, JsonRequestBehavior.AllowGet));
                                }
                            }
                            item.Oid = model.ID;
                            db.T_ManualExpressDetail.Add(item);
                        }
                        db.SaveChanges();
                        T_ManualExpressConfig  modelconfig  = db.T_ManualExpressConfig.SingleOrDefault(a => a.Step == 0 && a.Reason == "1");
                        T_ManualExpressAppRove AppRoveModel = new T_ManualExpressAppRove();
                        AppRoveModel.Status       = -1;
                        AppRoveModel.Step         = "0";
                        AppRoveModel.ApproveName  = Expense;
                        AppRoveModel.ApproveDName = modelconfig.Type;
                        AppRoveModel.Oid          = model.ID;
                        db.T_ManualExpressAppRove.Add(AppRoveModel);
                        db.SaveChanges();
                    }
                    else
                    {
                        return(Json(new { State = "Faile" }, JsonRequestBehavior.AllowGet));
                    }
                    //ModularByZP();
                    sc.Complete();
                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }