Ejemplo n.º 1
0
        public JsonResult InvoiceApplyApp(T_InvoiceApply model)
        {
            string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value);

            model.ApplyName = Nickname;
            model.ApplyDate = DateTime.Now;
            model.Status    = -1;
            model.Step      = 0;
            model.Isdelete  = 0;
            db.T_InvoiceApply.Add(model);

            int i = db.SaveChanges();

            if (i > 0)
            {
                T_InvoiceApplyConfig  modelconfig  = db.T_InvoiceApplyConfig.SingleOrDefault(a => a.Step == 0 && a.Reason == "1");
                T_InvoiceApplyAppRove AppRoveModel = new T_InvoiceApplyAppRove();
                AppRoveModel.Status = -1;
                AppRoveModel.Step   = "0";
                if (modelconfig.Name == null || modelconfig.Name == "")
                {
                    AppRoveModel.ApproveName = modelconfig.Type;
                }
                else
                {
                    AppRoveModel.ApproveName = modelconfig.Name;
                }
                AppRoveModel.ApproveDName = modelconfig.Type;
                AppRoveModel.Oid          = model.ID;
                db.T_InvoiceApplyAppRove.Add(AppRoveModel);
                db.SaveChanges();
                // ModularByZP();
                return(Json(i, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(i, JsonRequestBehavior.AllowGet));
            }
        }
Ejemplo n.º 2
0
        //审核
        public JsonResult InvoiceApplyCheck(T_InvoiceApply model, string status, string Memo)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                int            ID           = model.ID;
                T_InvoiceApply Invoicemodel = db.T_InvoiceApply.SingleOrDefault(a => a.ID == ID && a.Isdelete == 0);
                if (Invoicemodel == null)
                {
                    return(Json("数据可能被删除", JsonRequestBehavior.AllowGet));
                }

                T_InvoiceApplyAppRove modelApprove = db.T_InvoiceApplyAppRove.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_InvoiceApplyAppRove>(modelApprove).State = System.Data.Entity.EntityState.Modified;
                int i = db.SaveChanges();
                if (i > 0)
                {
                    if (status == "1")
                    {
                        T_InvoiceApplyAppRove newApprove = new T_InvoiceApplyAppRove();
                        int step = int.Parse(Invoicemodel.Step.ToString());
                        step++;
                        IQueryable <T_InvoiceApplyConfig> config = db.T_InvoiceApplyConfig.AsQueryable();
                        int stepLength = config.Count();//总共步骤
                        if (step < stepLength)
                        {
                            Invoicemodel.Status = 0;
                            T_InvoiceApplyConfig stepMod = db.T_InvoiceApplyConfig.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_InvoiceApplyAppRove.Add(newApprove);
                            db.SaveChanges();
                        }
                        else
                        {
                            Invoicemodel.Status = int.Parse(status);
                        }
                        Invoicemodel.Step = step;
                        db.Entry <T_InvoiceApply>(Invoicemodel).State = System.Data.Entity.EntityState.Modified;
                        int j = db.SaveChanges();
                        if (j > 0)
                        {
                            result = "保存成功";
                        }
                        else
                        {
                            result = "保存失败";
                        }
                    }
                    else
                    {
                        //不同意
                        Invoicemodel.Step   = 0;
                        Invoicemodel.Status = 2;
                        db.Entry <T_InvoiceApply>(Invoicemodel).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        //审核流程结束 申请人编辑后插入下一条记录
                        result = "保存成功";
                    }
                }
                else
                {
                    result = "保存失败";
                }
                //ModularByZP();
                sc.Complete();
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }