Esempio n. 1
0
        public ActionResult ViewElectronicInvoiceReportCheck(int ID)
        {
            ViewData["ID"] = ID;
            T_ElectronicInvoice        Model        = db.T_ElectronicInvoice.SingleOrDefault(a => a.ID == ID);
            T_ElectronicInvoiceAppRove modelApprove = db.T_ElectronicInvoiceAppRove.SingleOrDefault(a => a.Oid == ID && a.ApproveTime == null);
            T_ElectronicInvoice        MajorInvoice = new T_ElectronicInvoice();

            MajorInvoice = db.T_ElectronicInvoice.Single(a => a.ID == ID);
            List <T_ElectronicInvoiceAppRove> approve = db.T_ElectronicInvoiceAppRove.Where(a => a.Oid == ID).ToList();
            string table = "<table class=\"fromEditTable setTextWidth300\"> <tbody><tr><td>审核人</td><td>审核结果</td><td>审核时间</td><td>备注</td></tr>";
            string tr    = "";

            foreach (var item in approve)
            {
                string s = "";
                if (item.Status == -1)
                {
                    s = "<font color=#d02e2e>未审核</font>";
                }
                if (item.Status == 1)
                {
                    s = "<font color=#1fc73a>已同意</font>";
                }
                if (item.Status == 2)
                {
                    s = "<font color=#d02e2e>不同意</font>";
                }
                tr += string.Format("<tr><td><label>{0}</label></td><td>{1}</td><td>{2}</td><td>{3}</td></tr>", item.ApproveName, s, item.ApproveTime, item.Memo);
            }
            ViewData["history"]   = table + tr + "</tbody></table>";
            ViewData["approveid"] = ID;
            //  ViewData["Approve"] = modelApprove.ApproveDName;
            return(View(Model));
        }
Esempio n. 2
0
        //审核
        public JsonResult ElectronicInvoiceCheck(T_MajorInvoice model, string status, string Memo, string Memos)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                int ID = model.ID;
                T_ElectronicInvoice Invoicemodel = db.T_ElectronicInvoice.SingleOrDefault(a => a.ID == ID && a.Isdelete == "0");
                if (Invoicemodel == null)
                {
                    return(Json("数据可能被删除", JsonRequestBehavior.AllowGet));
                }
                string curName  = Server.UrlDecode(Request.Cookies["Name"].Value);
                string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value);

                List <T_ElectronicInvoiceGroup> RetreatGroupList = db.Database.SqlQuery <T_ElectronicInvoiceGroup>("select  * from T_ElectronicInvoiceGroup where Crew like '%" + Nickname + "%'").ToList();
                string GroupName = "";
                for (int i = 0; i < RetreatGroupList.Count; i++)
                {
                    if (i == 0)
                    {
                        GroupName += "'" + RetreatGroupList[i].GroupName + "'";
                    }
                    else
                    {
                        GroupName += "," + "'" + RetreatGroupList[i].GroupName + "'";
                    }
                }

                string sql = "select * from T_ElectronicInvoiceAppRove where Oid='" + ID + "' and ApproveTime is null ";
                if (GroupName != "" && GroupName != null)
                {
                    sql += "  and (ApproveName='" + Nickname + "' or ApproveName  in (" + GroupName + ")) ";
                }
                else
                {
                    sql += "    and ApproveName='" + Nickname + "'  ";
                }
                List <T_ElectronicInvoiceAppRove> AppRoveListModel = db.Database.SqlQuery <T_ElectronicInvoiceAppRove>(sql).ToList();
                if (AppRoveListModel.Count == 0)
                {
                    return(Json("该数据已审核,请勿重复审核", JsonRequestBehavior.AllowGet));
                }


                T_ElectronicInvoiceAppRove modelApprove = db.T_ElectronicInvoiceAppRove.FirstOrDefault(a => a.Oid == ID && a.ApproveTime == null);



                string result = "";
                modelApprove.ApproveName = Nickname;
                modelApprove.Memo        = Memo;
                modelApprove.ApproveTime = DateTime.Now;
                modelApprove.Status      = int.Parse(status);
                db.Entry <T_ElectronicInvoiceAppRove>(modelApprove).State = System.Data.Entity.EntityState.Modified;
                int z = db.SaveChanges();
                if (z > 0)
                {
                    if (status == "1")
                    {
                        T_ElectronicInvoiceAppRove newApprove = new T_ElectronicInvoiceAppRove();
                        int step = int.Parse(Invoicemodel.Step.ToString());
                        step++;

                        T_ElectronicInvoiceReason Reason = db.T_ElectronicInvoiceReason.SingleOrDefault(a => a.InvoiceReason == Invoicemodel.Invoicetype);
                        string Reasontype = "";
                        if (Reason == null)
                        {
                            Reasontype = "1";
                        }
                        else
                        {
                            Reasontype = Reason.Type;
                        }
                        List <T_ElectronicInvoiceConfig> config = db.T_ElectronicInvoiceConfig.Where(a => a.Reason == Reasontype).ToList();

                        int stepLength = config.Count();//总共步骤
                        if (step < stepLength)
                        {
                            Invoicemodel.Status = 0;
                            T_ElectronicInvoiceConfig stepMod = db.T_ElectronicInvoiceConfig.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_ElectronicInvoiceAppRove.Add(newApprove);
                            db.SaveChanges();
                        }
                        else
                        {
                            Invoicemodel.Status = int.Parse(status);
                        }
                        Invoicemodel.invoiceNum = Memos;
                        Invoicemodel.Step       = step;
                        db.Entry <T_ElectronicInvoice>(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_ElectronicInvoice>(Invoicemodel).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        //审核流程结束 申请人编辑后插入下一条记录
                        result = "保存成功";
                    }
                }
                else
                {
                    result = "保存失败";
                }

                sc.Complete();
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 3
0
        public JsonResult ElectronicInvoiceAdd(T_ElectronicInvoice model, string picUrls, string jsonStr)
        {
            string orderNumBer = model.OrderNumber;

            List <T_MajorInvoice> Nmodel = db.T_MajorInvoice.Where(a => a.OrderNumber == orderNumBer && a.Isdelete == "0").ToList();

            if (Nmodel.Count > 0)
            {
                return(Json(-1, JsonRequestBehavior.AllowGet));
            }
            string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value);

            model.PostUser    = Nickname;
            model.PostDate    = DateTime.Now;
            model.Status      = -1;
            model.Step        = 0;
            model.Isdelete    = "0";
            model.Invoicetype = model.ShopName;
            db.T_ElectronicInvoice.Add(model);

            int i = db.SaveChanges();

            if (i > 0)
            {
                List <T_ElectronicInvoiceDetails> details = App_Code.Com.Deserialize <T_ElectronicInvoiceDetails>(jsonStr);
                foreach (var item in details)
                {
                    if (item.specname == "undefined")
                    {
                        item.specname = "/";
                    }
                    item.Oid = model.ID;
                    db.T_ElectronicInvoiceDetails.Add(item);
                }
                db.SaveChanges();
                string InvoiceReason = model.Invoicetype;

                //先查看是选择的什么
                T_ElectronicInvoiceReason modelReason = db.T_ElectronicInvoiceReason.SingleOrDefault(a => a.InvoiceReason == InvoiceReason);

                string modelReasontype = "";
                if (modelReason == null)
                {
                    modelReasontype = "1";
                }
                else
                {
                    modelReasontype = modelReason.Type;
                }
                T_ElectronicInvoiceConfig  modelconfig  = db.T_ElectronicInvoiceConfig.SingleOrDefault(a => a.Step == 0 && a.Reason == modelReasontype);
                T_ElectronicInvoiceAppRove AppRoveModel = new T_ElectronicInvoiceAppRove();
                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_ElectronicInvoiceAppRove.Add(AppRoveModel);
                db.SaveChanges();
                if (picUrls.Length > 0)
                {
                    string[] picArr = picUrls.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);
                    foreach (string Purl in picArr)
                    {
                        T_ElectronicInvoiceEnclosure IndemnityPic = new T_ElectronicInvoiceEnclosure();
                        IndemnityPic.oid        = model.ID;
                        IndemnityPic.URL        = Purl;
                        IndemnityPic.uploadDate = DateTime.Now;
                        IndemnityPic.uploadName = Nickname;
                        db.T_ElectronicInvoiceEnclosure.Add(IndemnityPic);
                    }
                    db.SaveChanges();
                }

                return(Json(i, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(i, JsonRequestBehavior.AllowGet));
            }
        }