示例#1
0
        public ActionResult RepealSubmit(Billing data)
        {
            int id = data.IDX;
            int BillingType = 0;
            int idx = Util.toint(Request.Form["data[IDX]"].Trim());
            TugDataEntities db = new TugDataEntities();
            System.Linq.Expressions.Expression<Func<Billing, bool>> exp = u => u.IDX == idx;
            Billing billInfor = db.Billing.Where(exp).FirstOrDefault();

            int Phase = Convert.ToInt32(billInfor.Phase);
            int timeNo = Convert.ToInt32(billInfor.TimesNo);
            int curUserId = Session.GetDataFromSession<int>("userid");
            if (Phase > 1 || Phase == -1)  //流程已进入审核环节或已完成全部审核,不能撤销
            {
                var ret = new { code = Resources.Common.ERROR_CODE, message = "流程已进入审核环节,不能撤销!" };
                return Json(ret);
            }
            else
            {
                //更新Billing状态
                billInfor.Phase = 0;
                billInfor.Status = "已撤销提交";
                db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                string billtype = billInfor.InvoiceType.ToString();
                if (billtype == "特殊账单") BillingType = 1;

                //修改訂單表
                FinanceLogic.SetOrderServiceFlowingStatus(BillingType, idx, "否");

                //写入Approve表
                Approve addApprove = new Approve();
                addApprove.BillingID = idx;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = 0;
                addApprove.Task = "创建";
                addApprove.Accept = 3;
                addApprove.PersonID = curUserId;
                addApprove.UserID = curUserId;
                addApprove.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove = db.Approve.Add(addApprove);
                db.SaveChanges();
                return Json(new { message = "撤销成功!" });
            }
        }
示例#2
0
        public ActionResult RepealPass()
        {
            //int idx = Util.toint(Request.Form["data[IDX]"].Trim());
            var f = Request.Form;
            int BillingType = 0;
            int idx = Convert.ToInt32(Request.Form["data[IDX]"]);
            TugDataEntities db = new TugDataEntities();
            System.Linq.Expressions.Expression<Func<Billing, bool>> exp = u => u.IDX == idx;
            Billing billInfor = db.Billing.Where(exp).FirstOrDefault();

            int Phase = Convert.ToInt32(billInfor.Phase);
            int timeNo = Convert.ToInt32(billInfor.TimesNo);
            int tmpUserID =  Convert.ToInt32(Request.Form["data[UserID]"]);
            int curUserId = Session.GetDataFromSession<int>("userid");
            string billtype = billInfor.InvoiceType.ToString();
            if (billtype == "特殊账单") BillingType = 1;

            System.Linq.Expressions.Expression<Func<Flow, bool>> expF = u => u.BillingID == idx && u.MarkID == timeNo && u.FlowUserID == curUserId;
            Flow flowData = db.Flow.Where(expF).FirstOrDefault();
            if (tmpUserID == curUserId)

            {
                return Json(new { message = "该记录是您的提交任务,您无法撤销通过!" });
            }
            else if (Phase > flowData.Phase + 1)  //流程已进入下一审核环节,不能撤销
            {
                var ret = new { code = Resources.Common.ERROR_CODE, message = "已进入下一审核环节,不能撤销!" };
                return Json(ret);
            }
            else
            {
                //更新Billing表状态
                billInfor.Phase = 0;
                billInfor.Status = "已撤销通过";
                db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                //修改訂單表
                FinanceLogic.SetOrderServiceFlowingStatus(BillingType, idx, "否");

                //写入Approve表
                System.Linq.Expressions.Expression<Func<Approve, bool>> expA = u => u.BillingID == idx && u.FlowMark == timeNo && u.PersonID == curUserId;
                Approve approveInfor = db.Approve.Where(expA).FirstOrDefault(); //获取当前用户的审核信息

                Approve addApprove = new Approve();
                addApprove.BillingID = idx;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = approveInfor.Phase;
                addApprove.Task = approveInfor.Task;
                addApprove.Accept = 4;
                addApprove.PersonID = curUserId;
                addApprove.UserID = curUserId;
                addApprove.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove = db.Approve.Add(addApprove);
                db.SaveChanges();
                return Json(new { message = "撤销成功!" });
            }
        }
示例#3
0
        public ActionResult ApprovePass(List<int> passdata)
        {
            //var ids = Request.Form["data"];
            int curUserId = 0;
            TugDataEntities db = new TugDataEntities();
            curUserId = Session.GetDataFromSession<int>("userid");
            foreach (int id in passdata)
            {
                System.Linq.Expressions.Expression<Func<Billing, bool>> exp = u => u.IDX == id;
                Billing billInfor = db.Billing.Where(exp).FirstOrDefault();

                //写入Approve表
                Approve addApprove = new Approve();
                addApprove.BillingID = id;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = billInfor.Phase;
                addApprove.Task = Task(id, Convert.ToInt32(billInfor.Phase), Convert.ToInt32(billInfor.TimesNo));
                addApprove.Accept = 1;
                addApprove.PersonID = curUserId;
                addApprove.UserID = curUserId;
                addApprove.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove = db.Approve.Add(addApprove);
                db.SaveChanges();

                //判断是不是流程最后一步
                System.Linq.Expressions.Expression<Func<Flow, bool>> expFlow = u => u.BillingID == id && u.MarkID == billInfor.TimesNo;
                List<Flow> flowData = db.Flow.Where(expFlow).Select(u => u).ToList<Flow>();
                if (billInfor.Phase + 1 == flowData.Count)  //流程最后一步
                {
                    string billingCode = TugBusinessLogic.Utils.AutoGenerateBillCode();
                    //更改Billing状态
                    billInfor.Phase = -1;
                    billInfor.Status = "完成";
                    if (Util.checkdbnull(billInfor.BillingCode)=="") billInfor.BillingCode = billingCode;  //生成账单编号
                    billInfor.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();

                    //若账单有回扣单生成回扣单编号
                     System.Linq.Expressions.Expression<Func<Credit, bool>> expCredit = u => u.BillingID == id;
                     List<Credit> tmpCredit = db.Credit.Where(expCredit).Select(u => u).ToList<Credit>();
                     //Credit tmpCredit = db.Credit.Where(expCredit).FirstOrDefault();
                     if (tmpCredit.Count  != 0)
                     {
                         foreach (var item in tmpCredit)
                         {
                             if (Util.checkdbnull(item.CreditCode) == "")
                             {
                                 item.CreditCode = "C" + billInfor.BillingCode.Substring(1, billingCode.Length - 1);
                                 db.Entry(item).State = System.Data.Entity.EntityState.Modified;
                                 db.SaveChanges();
                             }

                         }
                     }
                }
                else
                {
                    //更改Billing状态
                    billInfor.Phase = billInfor.Phase + 1;
                    billInfor.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                    billInfor.Status = Task(id, Convert.ToInt32(billInfor.Phase), Convert.ToInt32(billInfor.TimesNo));
                    db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }
            }
            return Json(new { message = "审核完成!" });
        }
示例#4
0
        public ActionResult ApproveReject(List<int> rejectdata, string RejectReason)
        {
            int curUserId;
            int BillingType = 0;
            TugDataEntities db = new TugDataEntities();
            curUserId = Session.GetDataFromSession<int>("userid");
            foreach (int id in rejectdata)
            {
                //更改Billing状态
                System.Linq.Expressions.Expression<Func<Billing, bool>> exp = u => u.IDX == id;
                Billing billInfor = db.Billing.Where(exp).FirstOrDefault();
                string billtype = billInfor.InvoiceType.ToString();
                if (billtype == "特殊账单") BillingType = 1;

                billInfor.Phase = 0;
                billInfor.Status = "被駁回";
                db.Entry(billInfor).State = System.Data.Entity.EntityState.Modified;
                db.SaveChanges();

                //修改訂單表
                FinanceLogic.SetOrderServiceFlowingStatus(BillingType, id, "否");

                //写入Approve表
                Approve addApprove = new Approve();
                addApprove.BillingID = id;
                addApprove.FlowMark = billInfor.TimesNo;
                addApprove.Phase = billInfor.Phase;
                addApprove.Task = Task(id, Convert.ToInt32(billInfor.Phase), Convert.ToInt32(billInfor.TimesNo));
                addApprove.Accept = 0;
                addApprove.PersonID = curUserId;
                addApprove.UserID = curUserId;
                addApprove.CreateDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                addApprove = db.Approve.Add(addApprove);
                db.SaveChanges();
            }
            return Json(new { message = "操作完成!" });
        }
示例#5
0
        //BillingType:0普通账单,1特殊账单,2其他賬單
        public ActionResult SubmitFlow(int BillingType,string billids,List<string[]> dataListFromTable)
        {
            //billid 从Invoice页面传入
            //int[] arrbillid =new int[2]{1,2};
            string[] arrbillid = billids.Split(',');
            try
            {
                TugDataEntities db = new TugDataEntities();
                foreach (string sidx in arrbillid)
                {
                    int idx = Util.toint(sidx);
                    Billing billobj = db.Billing.Where(u => u.IDX == idx).FirstOrDefault();
                    if (billobj == null)
                    {
                        continue ;
                        //return Json(new { code = Resources.Common.ERROR_CODE, message = Resources.Common.ERROR_MESSAGE });
                    }
                    int newTimesNo =Util.toint(billobj.TimesNo) + 1;  //第几次流程
                    //将流程信息写入Flow表
                    #region
                    string mark = Util.GetSequence("F");
                    for(int i=0;i<dataListFromTable.Count-1;i++)//最后一行空行
                    {
                        TugDataModel.Flow obj = new Flow();
                        obj.BillingID = idx;
                        obj.MarkID = newTimesNo;
                        obj.Phase = i;
                        obj.Task =dataListFromTable[i][0] ;
                        string Name11=dataListFromTable[i][1];
                        UserInfor us1 = db.UserInfor.Where(u => u.Name1 == Name11).FirstOrDefault();
                        obj.FlowUserID = us1.IDX;
                        obj.StDate = dataListFromTable[i][2];
                        obj.EndDate =dataListFromTable[i][3] ;
                        obj.System = "Tug";
                        obj.OwnerID = -1;
                        obj.CreateDate = obj.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");;
                        obj.UserID = Session.GetDataFromSession<int>("userid");
                        //obj.State =0;
                        obj.Sign =mark;
                        //obj.UserDefinedCol1 = "";
                        //obj.UserDefinedCol2 = "";
                        //obj.UserDefinedCol3 = "";
                        //obj.UserDefinedCol4 = "";
                        //if (Request.Form["UserDefinedCol5"] != "")
                        //    obj.UserDefinedCol5 = Util.toint(Request.Form["UserDefinedCol5"]);
                        //obj.UserDefinedCol6 =;
                        //obj.UserDefinedCol7 =;
                        //obj.UserDefinedCol8 =;
                        //obj.UserDefinedCol9 = "";
                        //obj.UserDefinedCol10 = "";
                        obj = db.Flow.Add(obj);
                        db.SaveChanges();
                    }
            #endregion

                    //将提交审核写入Approve
                    #region
                    TugDataModel.Approve objapp = new Approve();
                    objapp.BillingID = idx;
                    objapp.FlowMark = newTimesNo;
                    objapp.Phase = 0;
                    objapp.Task = dataListFromTable[0][0];
                    objapp.Accept=2;
                    objapp.Remark="";
                    string Name12 = dataListFromTable[0][1];
                    UserInfor us2 = db.UserInfor.Where(u => u.Name1 == Name12).FirstOrDefault();
                    objapp.PersonID = us2.IDX;
                    objapp.System="Tug";
                    objapp.OwnerID=-1;
                    objapp.CreateDate = objapp.LastUpDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");;
                    objapp.UserID = Session.GetDataFromSession<int>("userid");
                    objapp = db.Approve.Add(objapp);
                    db.SaveChanges();
                    #endregion

                    //更新Billing表的流程信息
                    #region
                    billobj.TimesNo = newTimesNo;
                    billobj.Status = dataListFromTable[1][0];
                    billobj.Phase = 1;
                    db.Entry(billobj).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    #endregion
                    //更新orderinfor、orderservice表中的HasInFlow
                    //OrderLogic.UpdateHasInFlow(idx, "是");
                    if (BillingType!=2) FinanceLogic.SetOrderServiceFlowingStatus(BillingType, idx, "是");
                }

            }
            catch (Exception exp)
            {
                return Json(new { code = Resources.Common.EXCEPTION_CODE, message = Resources.Common.EXCEPTION_MESSAGE });
            }
            return Json(new { code = Resources.Common.SUCCESS_CODE, message = Resources.Common.SUCCESS_MESSAGE });
        }