Esempio n. 1
0
        public JsonResult DeleteInvoiceFinance(int ID)
        {
            T_ElectronicInvoice model = db.T_ElectronicInvoice.Find(ID);

            model.Isdelete = "1";
            db.Entry <T_ElectronicInvoice>(model).State = System.Data.Entity.EntityState.Modified;
            int i = db.SaveChanges();

            return(Json(i, JsonRequestBehavior.AllowGet));
        }
        public JsonResult DeleteInvoiceFinance(int ID)
        {
            T_HandwrittenExpress model = db.T_HandwrittenExpress.Find(ID);

            model.Isdelete = 1;
            db.Entry <T_HandwrittenExpress>(model).State = System.Data.Entity.EntityState.Modified;
            int i = db.SaveChanges();

            return(Json(i, JsonRequestBehavior.AllowGet));
        }
Esempio n. 3
0
        public JsonResult DeleteInvoiceApplyFinance(int ID)
        {
            T_InvoiceApply model = db.T_InvoiceApply.Find(ID);

            model.Isdelete = 1;
            db.Entry <T_InvoiceApply>(model).State = System.Data.Entity.EntityState.Modified;
            int i = db.SaveChanges();

            //ModularByZP();
            return(Json(i, JsonRequestBehavior.AllowGet));
        }
Esempio n. 4
0
 public JsonResult DeleteInvoiceFinance(int ID)
 {
     try
     {
         T_WDTHandOrder model = db.T_WDTHandOrder.Find(ID);
         model.Isdelete = 1;
         db.Entry <T_WDTHandOrder>(model).State = System.Data.EntityState.Modified;
         int i = db.SaveChanges();
         return(Json(i, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(0, ex.Message));
     }
 }
Esempio n. 5
0
 public JsonResult Delete(int ID)
 {
     try
     {
         T_MeetingRoom delModel = db.T_MeetingRoom.Find(ID);
         delModel.IsDelete = 1;
         db.Entry <T_MeetingRoom>(delModel).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new { State = "Faile", Message = e.Message }, JsonRequestBehavior.AllowGet));
     }
 }
        public JsonResult StockDetailAdd(T_StockStorage Model, string jsonStr)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                try
                {
                    string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value);
                    Model.Type      = "退货";
                    Model.ApplyName = Nickname;
                    Model.ApplyDate = DateTime.Now;
                    db.T_StockStorage.Add(Model);
                    db.SaveChanges();
                    List <T_StockDetail> details = App_Code.Com.Deserialize <T_StockDetail>(jsonStr);


                    foreach (var item in details)
                    {
                        item.Oid = Model.ID;
                        db.T_StockDetail.Add(item);
                        db.SaveChanges();
                        string  code          = item.Code;
                        string  WarehouseCode = Model.WarehouseCode;
                        T_Stock Smodel        = db.T_Stock.SingleOrDefault(a => a.Code == code && a.WarehouseName == WarehouseCode);
                        if (Smodel != null)
                        {
                            Smodel.Qty += item.Qty;
                            db.Entry <T_Stock>(Smodel).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                        else
                        {
                            T_Stock StModel = new T_Stock();
                            StModel.Qty           = item.Qty;
                            StModel.Name          = item.Name;
                            StModel.Code          = item.Code;
                            StModel.WarehouseName = WarehouseCode;
                            db.T_Stock.Add(StModel);
                            db.SaveChanges();
                        }

                        T_StockOutstorage StorageModel = new T_StockOutstorage();
                        StorageModel.Code          = item.Code;
                        StorageModel.Name          = item.Name;
                        StorageModel.WarehouseCode = WarehouseCode;
                        StorageModel.number        = Model.ID.ToString();
                        StorageModel.Qty           = item.Qty;
                        StorageModel.Type          = "入库";
                        db.T_StockOutstorage.Add(StorageModel);
                        db.SaveChanges();
                    }
                    sc.Complete();
                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
 public JsonResult ConfigEditSave(T_PersonnelPayRaiseConfig model)
 {
     try
     {
         T_PersonnelPayRaiseConfig editModel = db.T_PersonnelPayRaiseConfig.Find(model.ID);
         editModel.Name       = model.Name;
         editModel.Step       = model.Step;
         editModel.Type       = model.Type;
         editModel.isMultiple = model.isMultiple;
         db.Entry <T_PersonnelPayRaiseConfig>(editModel).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception e)
     {
         return(Json(new { State = "Faile", Message = e.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 8
0
 public JsonResult ViewSingleProductsplitCheckSave(string code)
 {
     using (TransactionScope sc = new TransactionScope())
     {
         T_goodsGY model = db.T_goodsGY.SingleOrDefault(a => a.code == code);
         model.isexamine = "1";
         db.Entry <T_goodsGY>(model).State = System.Data.Entity.EntityState.Modified;
         try
         {
             int i = db.SaveChanges();
             if (i > 0)
             {
                 App_Code.GY gy  = new App_Code.GY();
                 string      cmd = "";
                 cmd = "{" +
                       "\"appkey\":\"171736\"," +
                       "\"method\":\"gy.erp.item.add\"," +
                       "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," +
                       "\"code\":\"" + model.code + "\"," +
                       "\"name\":\"" + model.name + "\"," +
                       "\"simple_name\":\"" + model.simple_name + "\"," +
                       "\"skus\":[]" +
                       "}";
                 string sign    = gy.Sign(cmd);
                 string comcode = "{" +
                                  "\"appkey\":\"171736\"," +
                                  "\"method\":\"gy.erp.item.add\"," +
                                  "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," +
                                  "\"code\":\"" + model.code + "\"," +
                                  "\"name\":\"" + model.name + "\"," +
                                  "\"simple_name\":\"" + model.simple_name + "\"," +
                                  "\"sign\":\"" + sign + "\"," +
                                  "\"skus\":[]" +
                                  "}";
                 string   ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", comcode);
                 JsonData jsonData = null;
                 jsonData = JsonMapper.ToObject(ret);
                 string sd = jsonData[0].ToString();
                 if (sd == "True")
                 {
                     sc.Complete();
                     return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                 }
                 else
                 {
                     return(Json(new { State = "Faile", Message = "审核失败" }, JsonRequestBehavior.AllowGet));
                 }
             }
         }
         catch (DbEntityValidationException ex)
         {
             return(Json(new { State = "Faile", Message = "审核失败" }, JsonRequestBehavior.AllowGet));
         }
         return(Json(new { State = "Faile", Message = "审核失败" }, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 9
0
 public static void ModularRejectCount(string PendingAuditName, string ModularName, int Qty = 0)
 {
     try {
         EBMSEntities        db    = new EBMSEntities();
         T_ModularNotaudited model = db.T_ModularNotaudited.FirstOrDefault(a => a.ModularName == ModularName && a.PendingAuditName == PendingAuditName);
         model.ToupdateDate = DateTime.Now;
         model.RejectNumber = model.RejectNumber + Qty;
         db.Entry <T_ModularNotaudited>(model).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception e)
     {
     }
 }
Esempio n. 10
0
 //选择流程保存
 public JsonResult SelectSave(string method, string id, string shop, string reason, int money, string roles)
 {
     using (TransactionScope sc = new TransactionScope())
     {
         string result = "保存失败";
         if (id == "T")
         {
             //新增
             T_CashbackApproveConfig MOD_Config = new T_CashbackApproveConfig();
             MOD_Config.Shop   = shop;
             MOD_Config.Roles  = roles;
             MOD_Config.Reason = reason;
             MOD_Config.Method = int.Parse(method);
             MOD_Config.Money  = money;
             db.T_CashbackApproveConfig.Add(MOD_Config);
             int i = db.SaveChanges();
             if (i > 0)
             {
                 result = "保存成功";
             }
         }
         else
         {
             //修改
             int _id = int.Parse(id);
             T_CashbackApproveConfig MOD = db.T_CashbackApproveConfig.Find(_id);
             if (MOD == null)
             {
                 return(Json("保存失败", JsonRequestBehavior.AllowGet));
             }
             MOD.Shop   = shop;
             MOD.Roles  = roles;
             MOD.Reason = reason;
             MOD.Method = int.Parse(method);
             MOD.Money  = money;
             db.Entry <T_CashbackApproveConfig>(MOD).State = System.Data.Entity.EntityState.Modified;
             int i = db.SaveChanges();
             if (i > 0)
             {
                 result = "保存成功";
             }
         }
         sc.Complete();
         return(Json(result, JsonRequestBehavior.AllowGet));
     }
 }
Esempio n. 11
0
 public JsonResult RespiratorEditSave(T_RespiratorOrder model, string jsonStr)
 {
     using (TransactionScope sc = new TransactionScope())
     {
         try
         {
             T_RespiratorOrder order = db.T_RespiratorOrder.Find(model.ID);
             if (order != null)
             {
                 List <T_RespiratorOrderDetails> detail = Com.Deserialize <T_RespiratorOrderDetails>(jsonStr);
                 if (detail.Count == 0)
                 {
                     return(Json(new { State = "Faile", Message = "请添加详情" }, JsonRequestBehavior.AllowGet));
                 }
                 else
                 {
                     foreach (var item in detail)
                     {
                         T_RespiratorOrderDetails editDetail = db.T_RespiratorOrderDetails.Find(item.ID);
                         editDetail.Company     = item.Company;
                         editDetail.Number      = item.Number;
                         editDetail.Price       = item.Price;
                         editDetail.ProductCode = item.ProductCode;
                         editDetail.ProductName = item.ProductName;
                         editDetail.Subtotal    = item.Subtotal;
                         db.Entry <T_RespiratorOrderDetails>(editDetail).State = System.Data.Entity.EntityState.Modified;
                     }
                     db.SaveChanges();
                     sc.Complete();
                     return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                 }
             }
             else
             {
                 return(Json(new { State = "Faile", Message = "保存失败" }, JsonRequestBehavior.AllowGet));
             }
         }
         catch (Exception ex)
         {
             return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
         }
     }
 }
Esempio n. 12
0
        public JsonResult EditSave(T_CheckAttendace model)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                try
                {
                    T_CheckAttendace editModel = db.T_CheckAttendace.Find(model.ID);

                    editModel.CurrentApprove = model.CurrentApprove;
                    editModel.Days           = model.Days;
                    editModel.EndTime        = model.EndTime;
                    editModel.Mode           = model.Mode;
                    editModel.Reason         = model.Reason;
                    editModel.StartTime      = model.StartTime;
                    editModel.WorkEndTime    = model.WorkEndTime;
                    editModel.WorkStartTime  = model.WorkStartTime;
                    editModel.IsDelete       = 0;
                    if (model.LeaveType == null || model.LeaveType == "")
                    {
                        model.LeaveType = model.Type;
                    }
                    if (editModel.Status == 2)
                    {
                        editModel.Status = -1;
                        editModel.Step   = 1;
                        T_CheckAttendanceApprove approve = new T_CheckAttendanceApprove();
                        approve.Status      = -1;
                        approve.ApproveName = model.CurrentApprove;
                        approve.PID         = model.ID;
                        approve.Step        = 1;
                        db.T_CheckAttendanceApprove.Add(approve);
                        db.SaveChanges();
                    }
                    db.Entry <T_CheckAttendace>(editModel).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                    //ModularByZP();
                    sc.Complete();
                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                catch (DbEntityValidationException e)
                {
                    return(Json(new { State = "Faile", Message = e.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Esempio n. 13
0
        public void ModularByZP()
        {
            List <T_ModularNotaudited> ModularNotaudited = db.T_ModularNotaudited.Where(a => a.ModularName == "招聘").ToList();

            if (ModularNotaudited.Count > 0)
            {
                foreach (var item in ModularNotaudited)
                {
                    db.T_ModularNotaudited.Remove(item);
                }
                db.SaveChanges();
            }
            string         RetreatAppRoveSql   = "select Interviewer as PendingAuditName,COUNT(*) as NotauditedNumber from T_PersonnelInterviewRecord where PID in (select ID from T_PersonnelFile where  Isdelete='0'  and (InterviewState = -1 or InterviewState = 0) )  and  State=0 and Date is null GROUP BY Interviewer";
            List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList();

            // string Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value);
            for (int e = 0; e < RetreatAppRoveQuery.Count; e++)
            {
                string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;

                T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "招聘" && a.PendingAuditName == PendingAuditName);
                if (NotauditedModel != null)
                {
                    NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                    db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                    ModularNotauditedModel.ModularName      = "招聘";
                    ModularNotauditedModel.RejectNumber     = 0;
                    ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                    ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;
                    ModularNotauditedModel.ToupdateDate     = DateTime.Now;
                    ModularNotauditedModel.ToupdateName     = "admin";
                    db.T_ModularNotaudited.Add(ModularNotauditedModel);
                }
                db.SaveChanges();
            }
            //招聘部分没有
        }
        public void ModularByZP()
        {
            List <T_ModularNotaudited> ModularNotaudited = db.T_ModularNotaudited.Where(a => a.ModularName == "部门活动").ToList();

            if (ModularNotaudited.Count > 0)
            {
                foreach (var item in ModularNotaudited)
                {
                    db.T_ModularNotaudited.Remove(item);
                }
                db.SaveChanges();
            }

            string         RetreatAppRoveSql   = " select ApproveName as PendingAuditName,COUNT(*) as NotauditedNumber from  T_DepartmentActivityApprove where Pid in (select ID from T_DepartmentActivity where(Status = -1 or Status = 0) and IsDelete = 0) and Status = 0 and ApproveTime is null GROUP BY ApproveName";
            List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList();
            string         Nickname            = Server.UrlDecode(Request.Cookies["Nickname"].Value);

            for (int e = 0; e < RetreatAppRoveQuery.Count; e++)
            {
                string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;

                T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "部门活动" && a.PendingAuditName == PendingAuditName);
                if (NotauditedModel != null)
                {
                    NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                    db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                    ModularNotauditedModel.ModularName      = "部门活动";
                    ModularNotauditedModel.RejectNumber     = 0;
                    ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                    ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;
                    ModularNotauditedModel.ToupdateDate     = DateTime.Now;
                    ModularNotauditedModel.ToupdateName     = Nickname;
                    db.T_ModularNotaudited.Add(ModularNotauditedModel);
                }
                db.SaveChanges();
            }


            //增加驳回数据
            string         RejectNumberSql   = "select PostUser as PendingAuditName,COUNT(*) as NotauditedNumber from T_DepartmentActivity where Status='2' and IsDelete=0  GROUP BY PostUser  ";
            List <Modular> RejectNumberQuery = db.Database.SqlQuery <Modular>(RejectNumberSql).ToList();

            for (int e = 0; e < RejectNumberQuery.Count; e++)
            {
                string PendingAuditName = RejectNumberQuery[e].PendingAuditName;

                T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "部门活动" && a.PendingAuditName == PendingAuditName);
                if (NotauditedModel != null)
                {
                    NotauditedModel.RejectNumber = RejectNumberQuery[e].NotauditedNumber;
                    db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.Entity.EntityState.Modified;
                }
                else
                {
                    T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                    ModularNotauditedModel.ModularName      = "部门活动";
                    ModularNotauditedModel.NotauditedNumber = 0;
                    ModularNotauditedModel.RejectNumber     = RejectNumberQuery[e].NotauditedNumber;
                    ModularNotauditedModel.PendingAuditName = RejectNumberQuery[e].PendingAuditName;
                    ModularNotauditedModel.ToupdateDate     = DateTime.Now;
                    ModularNotauditedModel.ToupdateName     = Nickname;
                    db.T_ModularNotaudited.Add(ModularNotauditedModel);
                }
                db.SaveChanges();
            }
        }
Esempio n. 15
0
        //审核
        public JsonResult SecurityCodeCheck(T_SecurityCode model, string status, string Memo)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                int            ID           = model.ID;
                T_SecurityCode Invoicemodel = db.T_SecurityCode.SingleOrDefault(a => a.ID == ID && a.Isdelete == 0);
                if (Invoicemodel == null)
                {
                    return(Json("数据可能被删除", JsonRequestBehavior.AllowGet));
                }

                T_SecurityCodeAppRove modelApprove = db.T_SecurityCodeAppRove.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_SecurityCodeAppRove>(modelApprove).State = System.Data.Entity.EntityState.Modified;
                int i = db.SaveChanges();
                if (i > 0)
                {
                    if (status == "1")
                    {
                        T_SecurityCodeAppRove newApprove = new T_SecurityCodeAppRove();
                        int step = int.Parse(Invoicemodel.Step.ToString());
                        step++;
                        IQueryable <T_SecurityCodeConfig> config = db.T_SecurityCodeConfig.AsQueryable();
                        int stepLength = config.Count();//总共步骤
                        if (step < stepLength)
                        {
                            Invoicemodel.Status = 0;
                            T_SecurityCodeConfig stepMod = db.T_SecurityCodeConfig.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_SecurityCodeAppRove.Add(newApprove);
                            db.SaveChanges();
                        }
                        else
                        {
                            Invoicemodel.Status = int.Parse(status);
                        }
                        Invoicemodel.Step = step;
                        db.Entry <T_SecurityCode>(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_SecurityCode>(Invoicemodel).State = System.Data.Entity.EntityState.Modified;
                        db.SaveChanges();
                        //审核流程结束 申请人编辑后插入下一条记录
                        result = "保存成功";
                    }
                }
                else
                {
                    result = "保存失败";
                }

                sc.Complete();
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 16
0
        public JsonResult Check(string UserName, int approveID, int status, string memo)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                try
                {
                    int TotalStep = db.T_ExchangeCenterConfig.ToList().Count;
                    T_ExchangeCenterApprove approve = db.T_ExchangeCenterApprove.Find(approveID);
                    string           name           = approve.ApproveName;
                    T_ExchangeCenter model          = db.T_ExchangeCenter.Find(approve.Pid);
                    approve.ApproveName   = UserName;
                    approve.ApproveStatus = status;
                    approve.ApproveTime   = DateTime.Now;
                    approve.Memo          = memo;
                    db.SaveChanges();
                    if (status == 2)//不同意
                    {
                        model.Status = status;
                        model.Step   = model.Step + 1;
                        db.SaveChanges();
                    }
                    else//同意
                    {
                        int type     = db.T_ExchangeReson.SingleOrDefault(s => s.Reson.Equals(model.ExchangeReson)).Type;
                        int LastStep = db.T_ExchangeCenterConfig.OrderByDescending(s => s.Step).FirstOrDefault(s => s.Reson == type).Step;
                        if (LastStep > model.Step)//判断是否存在下一级
                        {
                            //获得下一级审核部门
                            string nextapproveType             = db.T_ExchangeCenterConfig.OrderBy(s => s.Step).FirstOrDefault(s => s.Reson == type && s.Step > model.Step).ApproveType;
                            T_ExchangeCenterApprove newApprove = new T_ExchangeCenterApprove();
                            newApprove.ApproveStatus = -1;
                            newApprove.ApproveName   = nextapproveType;
                            newApprove.ApproveTime   = null;
                            newApprove.Pid           = approve.Pid;
                            db.T_ExchangeCenterApprove.Add(newApprove);
                            db.SaveChanges();
                            model.Status = 0;
                            model.Step   = model.Step + 1;
                            db.SaveChanges();
                        }
                        if (name.Equals("售后主管") || name.Equals("呼吸机主管"))//售后主管审核后直接加入补发货
                        {
                            //T_OrderList order = db.T_OrderList.Find(model.OrderId);
                            List <T_ExchangeDetail> exchangedetail = db.T_ExchangeDetail.Where(s => s.ExchangeCenterId == model.ID).ToList();

                            #region 加入快递赔付

                            if (model.ExchangeReson.Equals("快递破损"))
                            {
                                GY     gy  = new GY();
                                string cmd = "";

                                cmd = "{" +
                                      "\"appkey\":\"171736\"," +
                                      "\"method\":\"gy.erp.trade.get\"," +
                                      "\"page_no\":1," +
                                      "\"page_size\":10," +
                                      "\"platform_code\":\"" + model.OrderCode + "\"," +
                                      "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                                      "}";

                                string sign = gy.Sign(cmd);
                                cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                                string   ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                                JsonData jsonData = null;
                                jsonData = JsonMapper.ToObject(ret);

                                if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                                {
                                    cmd = "{" +
                                          "\"appkey\":\"171736\"," +
                                          "\"method\":\"gy.erp.trade.history.get\"," +
                                          "\"page_no\":1," +
                                          "\"page_size\":10," +
                                          "\"platform_code\":\"" + model.OrderCode + "\"," +
                                          "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                                          "}";
                                    sign     = gy.Sign(cmd);
                                    cmd      = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                                    ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                                    jsonData = null;
                                    jsonData = JsonMapper.ToObject(ret);
                                    if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                                    {
                                        return(Json(new { State = "Faile", Message = "订单号不存在" }));
                                    }
                                }
                                JsonData jsonOrders = jsonData["orders"][0];
                                var      deliver    = jsonOrders["deliverys"][0];
                                //快递单号
                                string mail_no = isNULL(deliver["mail_no"]).ToString();
                                //订单金额
                                string amount = isNULL(jsonOrders["amount"]).ToString();
                                //快递名称
                                string             express_name = isNULL(jsonOrders["express_name"]).ToString();
                                T_ExpressIndemnity Inde         = new T_ExpressIndemnity
                                {
                                    PostUserName       = model.PostUser,
                                    Date               = DateTime.Now,
                                    OrderNum           = model.OrderCode,
                                    wangwang           = model.VipCode,
                                    ShopName           = model.StoreName,
                                    RetreatExpressNum  = mail_no,
                                    State              = "0",
                                    OrderMoney         = Convert.ToDouble(amount),
                                    Type               = "破损",
                                    Second             = "0",
                                    CurrentApproveName = "快递组",
                                    IsDelete           = 0,
                                    ExpressName        = express_name,
                                    IndemnityMoney     = 0
                                };
                                db.T_ExpressIndemnity.Add(Inde);
                                db.SaveChanges();
                                List <T_ExchangePic> picList = db.T_ExchangePic.Where(s => s.ExchangeId == model.ID).ToList();
                                foreach (var item in picList)
                                {
                                    T_ExpressIndemnityPic expressPic = new T_ExpressIndemnityPic
                                    {
                                        EID    = Inde.ID,
                                        PicURL = item.Url
                                    };
                                    db.T_ExpressIndemnityPic.Add(expressPic);
                                }
                                db.SaveChanges();
                            }

                            #endregion

                            //#region 新增订单数据

                            //string newOrderCode = "";
                            //string newCode = "";
                            //string usedOrderCode = model.OrderCode;
                            //string userCode = order.code;
                            //List<T_OrderList> HEmodel = db.T_OrderList.Where(a => a.platform_code.Contains(usedOrderCode)).ToList();
                            //List<T_OrderList> orderList = db.T_OrderList.Where(a => a.code.Contains(userCode)).ToList();
                            //if (HEmodel.Count > 1)
                            //{
                            //    string HEmodelCount = HEmodel.Count.ToString();
                            //    newOrderCode = usedOrderCode + HEmodelCount;
                            //}
                            //else
                            //    newOrderCode = usedOrderCode + "1";
                            //if (orderList.Count > 1)
                            //{
                            //    string listCount = orderList.Count.ToString();
                            //    newCode = userCode + listCount;
                            //}
                            //else
                            //    newCode = userCode + "1";
                            //model.NewOrderCode = newOrderCode;
                            //db.SaveChanges();
                            //T_OrderList newOrder = new T_OrderList
                            //{
                            //    code = newCode,
                            //    order_type_name = "换货订单",
                            //    platform_code = newOrderCode,
                            //    createtime = DateTime.Now,
                            //    dealtime = model.SingleTime.ToString(),
                            //    cod = order.cod,
                            //    approve = order.approve,
                            //    delivery_state = order.delivery_state,
                            //    warehouse_code = model.ReturnWarhouse,
                            //    warehouse_name = db.T_Warehouses.SingleOrDefault(s => s.code.Equals(model.ReturnWarhouse)).name,
                            //    shop_code = model.StoreCode,
                            //    shop_name = model.StoreName,
                            //    express_code = model.ReturnExpressName,
                            //    express_name = db.T_Express.SingleOrDefault(s => s.Code.Equals(model.ReturnExpressName)).Name,
                            //    buyer_memo = model.BuyRemark,
                            //    seller_memo = model.SalesRemark,
                            //    vip_code = model.VipCode,
                            //    vip_name = model.VipName,
                            //    receiver_name = model.ReceivingName,
                            //    receiver_mobile = model.ReceivingTelPhone,
                            //    receiver_phone = model.ReceivingPhone,
                            //    receiver_zip = model.NeedPostalCode,
                            //    receiver_area = model.AddressMessage,
                            //    receiver_address = model.ReceivingAddress,
                            //    payCode = order.payCode,
                            //    vipIdCard = order.vipIdCard,
                            //    vipRealName = order.vipRealName,
                            //    vipEmail = order.vipEmail,
                            //    amount = 0,
                            //    payment_amount = 0,
                            //    post_fee = 0,
                            //    discount_fee = 0,
                            //    payment = 0,
                            //    qty = "1",
                            //    weight_origin = "0",
                            //    post_cost = 0,
                            //    mail_no = model.ReturnExpressCode,
                            //    platform_flag = "0",
                            //    IsGeneralize = 0,
                            //    Status_CashBack = 0,
                            //    Status_Retreat = 0,
                            //    Status_ExpressIndemnity = 0,
                            //    ExchangeStatus = 0,
                            //    ReissueStatus = 0
                            //};
                            //db.T_OrderList.Add(newOrder);
                            //db.SaveChanges();
                            //foreach (var item in exchangedetail)
                            //{
                            //    T_OrderDetail Orderdetail = db.T_OrderDetail.FirstOrDefault(s => s.oid.Equals(order.code) && s.item_code.Equals(item.SendProductCode));
                            //    if (Orderdetail != null)//修改原订单详情换货状态与换货数量
                            //    {
                            //        Orderdetail.ExchangeStatus = 1;
                            //        Orderdetail.ExchangeQty += item.SendProductNum;
                            //        db.SaveChanges();
                            //    }
                            //    T_OrderDetail t = new T_OrderDetail
                            //    {
                            //        oid = newCode,
                            //        refund = 0,
                            //        item_code = item.NeedProductCode,
                            //        item_name = item.NeedProductName,
                            //        item_simple_name = "",
                            //        sku_code = "",
                            //        sku_name = "",
                            //        qty = 0,
                            //        price = 0,
                            //        amount = 0,
                            //        discount_fee = 0,
                            //        amount_after = 0,
                            //        post_fee = 0,
                            //        platform_item_name = "",
                            //        platform_sku_name = "",
                            //        note = "",
                            //        ExchangeStatus = 0,
                            //        ExchangeQty = 0,
                            //        ReissueStatus = 0,
                            //        ReissueQty = 0,
                            //        RetreatQty = 0,
                            //        RetreatStatus = 0
                            //    };
                            //    db.T_OrderDetail.Add(t);
                            //    db.SaveChanges();
                            //}

                            //#endregion

                            #region 加入补发货

                            string    remark = "";
                            T_Reissue re     = db.T_Reissue.FirstOrDefault(s => s.OrderCode.Equals(model.OrderCode) && s.IsDelete == 0);
                            if (re != null)
                            {
                                var date      = Convert.ToDateTime(DateTime.Now).ToString("yyyyMMdd");
                                var modeldate = Convert.ToDateTime(re.CreatDate).ToString("yyyyMMdd");

                                if (re != null && int.Parse(date) - int.Parse(modeldate) <= 3)
                                {
                                    remark = model.SystemRemark + "3天内补发货重复";
                                }
                            }
                            //更改订单主表补发货状态
                            //else
                            //{
                            //    order.ReissueStatus = 1;
                            //    db.SaveChanges();
                            //}
                            T_Reissue reissue = new T_Reissue
                            {
                                OrderCode      = model.OrderCode,
                                NewOrderCode   = "8" + DateTime.Now.ToString("yyyyMMddHHmmss"),
                                VipName        = model.VipName,
                                StoreName      = model.StoreName,
                                WarhouseName   = model.NeedWarhouse,
                                ExpressName    = model.NeedExpress,
                                OrderType      = "Return",
                                SingleTime     = model.SingleTime,
                                ReceivingName  = model.ReceivingName,
                                PostalCode     = model.NeedPostalCode,
                                Phone          = model.ReceivingPhone,
                                TelPhone       = model.ReceivingTelPhone,
                                VipCode        = model.VipCode,
                                Address        = model.ReceivingAddress,
                                AddressMessage = model.AddressMessage,
                                SalesRemark    = model.SalesRemark,
                                BuyRemark      = model.BuyRemark,
                                StoreCode      = model.StoreCode,
                                Step           = 0,
                                Status         = -2,
                                BusinessName   = Com.GetReissueName(model.StoreCode, model.ExchangeReson),
                                PostUser       = model.PostUser,
                                DraftName      = Com.GetReissueName(model.StoreCode, model.ExchangeReson),
                                CreatDate      = DateTime.Now,
                                IsDelete       = 0,
                                ReissueReson   = model.ExchangeReson,
                                SystemRemark   = remark
                            };
                            db.T_Reissue.Add(reissue);
                            db.SaveChanges();
                            IQueryable <T_ExchangeDetail> detail = db.T_ExchangeDetail.Where(s => s.ExchangeCenterId == model.ID);
                            foreach (var item in detail)
                            {
                                T_ReissueDetail items = new T_ReissueDetail
                                {
                                    ProductCode = item.NeedProductCode,
                                    ProductName = item.NeedProductName,
                                    Num         = item.NeedProductNum,
                                    ReissueId   = reissue.ID
                                };
                                db.T_ReissueDetail.Add(items);
                            }
                            db.SaveChanges();

                            #endregion

                            #region 判断仓库是否收货

                            T_ReturnToStorage storge = db.T_ReturnToStorage.SingleOrDefault(s => s.Retreat_expressNumber.Equals(model.ReturnExpressCode));
                            if (storge != null)
                            {
                                //List<T_ExchangeCenter> exchange = db.T_ExchangeCenter.Where(s => s.OrderCode.Equals(model.OrderCode) && s.IsDelete == 0).ToList();

                                model.WarhouseStatus = 1;
                                model.Status         = 1;
                                T_ExchangeCenterApprove approve1 = db.T_ExchangeCenterApprove.SingleOrDefault(s => s.ApproveName.Equals("仓库") && !s.ApproveTime.HasValue && s.Pid == model.ID);
                                approve1.ApproveName   = "仓库";
                                approve1.ApproveStatus = 1;
                                approve1.ApproveTime   = DateTime.Now;
                                //判断是否第一次换货,如果是则修改订单状态为已收货
                                //if (exchange.Count() == 1)
                                //{
                                //    order.ExchangeStatus = 2;
                                //}
                            }


                            #endregion
                        }
                    }
                    List <T_ModularNotaudited> ModularNotaudited = db.T_ModularNotaudited.Where(a => a.ModularName == "换货未审核").ToList();
                    if (ModularNotaudited.Count > 0)
                    {
                        foreach (var item in ModularNotaudited)
                        {
                            db.T_ModularNotaudited.Remove(item);
                        }
                        db.SaveChanges();
                    }
                    string         RetreatAppRoveSql   = "  select isnull(ApproveUser,ApproveName) as PendingAuditName,COUNT(*) as NotauditedNumber from T_ExchangeCenterApprove where  Pid in ( select ID from T_ExchangeCenter where IsDelete=0 ) and  ApproveStatus=-1 and ApproveTime is null GROUP BY ApproveName,ApproveUser";
                    List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList();
                    string         Nickname            = Server.UrlDecode(Request.Cookies["Nickname"].Value);
                    for (int e = 0; e < RetreatAppRoveQuery.Count; e++)
                    {
                        string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;

                        T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "换货未审核" && a.PendingAuditName == PendingAuditName);
                        if (NotauditedModel != null)
                        {
                            NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                            db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified;
                        }
                        else
                        {
                            T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                            ModularNotauditedModel.ModularName      = "换货未审核";
                            ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                            ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;
                            ModularNotauditedModel.ToupdateDate     = DateTime.Now; ModularNotauditedModel.ToupdateName = Nickname;
                            db.T_ModularNotaudited.Add(ModularNotauditedModel);
                        }
                        db.SaveChanges();
                    }
                    sc.Complete();
                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Esempio n. 17
0
        public JsonResult Check(string CurUser, int approveId, int status, string memo, decimal usedMoney = 0)
        {
            var Approve         = db.T_FreezeApprove.Find(approveId);
            var model           = db.T_Freeze.FirstOrDefault(s => s.ID == Approve.freezeID);
            int step            = model.Step;
            var configNextModel = db.T_FreezeConfig.FirstOrDefault(s => s.Step > step);

            Approve.ApproveTime = DateTime.Now;
            Approve.Memo        = memo;
            try
            {
                //同意
                if (status == 3)
                {
                    Approve.ApproveStatus = 3;
                    //是否存在下一级
                    if (configNextModel != null)
                    {
                        model.Step  = configNextModel.Step;
                        model.state = 1;
                        var approveModel = new T_FreezeApprove();
                        approveModel.ApproveName   = configNextModel.ApproveUser;
                        approveModel.ApproveStatus = -1;
                        approveModel.freezeID      = model.ID;
                        db.T_FreezeApprove.Add(approveModel);
                    }
                    else
                    {
                        if (usedMoney > model.freezeMoney)
                        {
                            return(Json(new { State = "Faile", Message = "使用金额不能大于冻结金额" }, JsonRequestBehavior.AllowGet));
                        }
                        model.state        = 2;
                        model.usedMoney    = usedMoney;
                        model.surplusMoney = model.freezeMoney - model.usedMoney;
                    }
                }
                //不同意
                else
                {
                    Approve.ApproveStatus = 4;
                    model.state           = 4;
                    model.Step            = db.T_FreezeConfig.OrderBy(s => s.Step).First().Step;
                }
                var i = db.SaveChanges();


                if (i > 0)
                {
                    string         RetreatAppRoveSql   = " select ApproveName as PendingAuditName,COUNT(*) as NotauditedNumber from T_FreezeApprove where  freezeID in ( select ID from T_Freeze where isDelete=0 ) and  ApproveStatus=-1 and ApproveTime is null GROUP BY ApproveName ";
                    List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList();
                    string         Nickname            = CurUser;
                    for (int e = 0; e < RetreatAppRoveQuery.Count; e++)
                    {
                        string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;

                        T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "资金冻结未审核" && a.PendingAuditName == PendingAuditName);
                        if (NotauditedModel != null)
                        {
                            NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                            db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified;
                        }
                        else
                        {
                            T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                            ModularNotauditedModel.ModularName      = "资金冻结未审核";
                            ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                            ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;
                            ModularNotauditedModel.ToupdateDate     = DateTime.Now; ModularNotauditedModel.ToupdateName = Nickname;
                            db.T_ModularNotaudited.Add(ModularNotauditedModel);
                        }
                        db.SaveChanges();
                    }

                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { State = "Faile", Message = "操作失败" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 18
0
 //给目标部门的父级部门人员字段插入人员ID方法
 public void addEmployeesToDepartmentForEidt(int pid, string sId)
 {
     //pid是目标部门的Id, sId是人员ID
     if (pid != -1)
     {
         T_Department departmentEndModel = db.T_Department.Find(pid);                            //找到目标门数据
         string       endEm = departmentEndModel.employees;                                      //目标部门的人员字段
         int          endDepartmentParentID = int.Parse(departmentEndModel.parentId.ToString()); //目标部门父ID
         string       str2 = "";
         if (endEm != null && endEm != "")
         {
             str2 += endEm + "," + sId;
         }
         else
         {
             str2 += sId;
         }
         departmentEndModel.employees = str2;
         db.Entry <T_Department>(departmentEndModel).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
         addEmployeesToDepartmentForEidt(endDepartmentParentID, sId);
     }
 }
Esempio n. 19
0
        public JsonResult Check(int id, int status, string memo, string checkMan, string CurUser)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                T_LossReportApprove modelApprove = db.T_LossReportApprove.FirstOrDefault(a => a.Oid == id && a.ApproveTime == null);
                T_User MOD_User = db.T_User.FirstOrDefault(a => a.Nickname == CurUser);
                //真名
                string curName = MOD_User.Name;
                T_LossReportApproveConfig financeMod = db.T_LossReportApproveConfig.SingleOrDefault(a => a.Type == "财务主管");//审核财务主管一步
                string financeAdmin = financeMod.Name;
                string result       = "";
                if (modelApprove == null)
                {
                    return(Json("数据可能被删除", JsonRequestBehavior.AllowGet));
                }
                modelApprove.Memo        = memo;
                modelApprove.ApproveTime = DateTime.Now;
                modelApprove.Status      = status;
                db.Entry <T_LossReportApprove>(modelApprove).State = System.Data.EntityState.Modified;
                int i = db.SaveChanges();
                if (i > 0)
                {
                    T_LossReport        model      = db.T_LossReport.Find(id);
                    T_LossReportApprove newApprove = new T_LossReportApprove();
                    if (model == null)
                    {
                        return(Json("数据可能被删除", JsonRequestBehavior.AllowGet));
                    }
                    if (status == 1)
                    {
                        //同意
                        int step = int.Parse(model.Step.ToString());
                        step++;
                        IQueryable <T_LossReportApproveConfig> config = db.T_LossReportApproveConfig.AsQueryable();
                        int stepLength = config.Count();//总共步骤
                        if (step < stepLength)
                        {
                            //不是最后一步,主表状态为0 =>审核中
                            model.Status = 0;
                            T_LossReportApproveConfig stepMod = db.T_LossReportApproveConfig.SingleOrDefault(a => a.Step == step);
                            string nextName = stepMod.Name;
                            //下一步审核人不是null  审核记录插入一条新纪录
                            newApprove.Memo   = "";
                            newApprove.Oid    = id;
                            newApprove.Status = -1;
                            if (nextName != null)
                            {
                                newApprove.ApproveName = nextName;
                            }
                            if (curName == financeAdmin && model.Step > 0) //如果是以财务主管来审核
                            {
                                newApprove.ApproveName = checkMan;
                            }
                            db.T_LossReportApprove.Add(newApprove);
                            db.SaveChanges();
                        }
                        else
                        {
                            //最后一步,主表状态改为 1 => 同意
                            model.Status = status;
                        }
                        model.Step = step;
                        db.Entry <T_LossReport>(model).State = System.Data.EntityState.Modified;
                        int j = db.SaveChanges();
                        if (j > 0)
                        {
                            result = "保存成功";
                        }
                        else
                        {
                            result = "保存失败";
                        }
                    }
                    else
                    {
                        //不同意
                        model.Step   = 0;
                        model.Status = 2;
                        db.Entry <T_LossReport>(model).State = System.Data.EntityState.Modified;
                        db.SaveChanges();
                        //审核流程结束 申请人编辑后插入下一条记录
                        result = "保存成功";
                    }
                }
                else
                {
                    result = "保存失败";
                }
                string         RetreatAppRoveSql   = " select ApproveName as PendingAuditName,COUNT(*) as NotauditedNumber from T_LossReportApprove where  Oid in ( select ID from T_LossReport where Status!=3 and IsDelete=0 ) and  Status=-1 and ApproveTime is null GROUP BY ApproveName ";
                List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList();
                string         Nickname            = CurUser;
                for (int e = 0; e < RetreatAppRoveQuery.Count; e++)
                {
                    string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;

                    T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "报损" && a.PendingAuditName == PendingAuditName);
                    if (NotauditedModel != null)
                    {
                        NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                        db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified;
                    }
                    else
                    {
                        T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                        ModularNotauditedModel.ModularName      = "报损";
                        ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                        ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;
                        ModularNotauditedModel.ToupdateDate     = DateTime.Now; ModularNotauditedModel.ToupdateName = Nickname;
                        db.T_ModularNotaudited.Add(ModularNotauditedModel);
                    }
                    db.SaveChanges();
                }


                sc.Complete();
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 20
0
        //审核
        public JsonResult Check(int id, int status, string memo, string method, int cashier, string backfrom, string CurUser)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                //当前用户
                string curUser = CurUser;
                //审核主记录
                T_CashBack MOD_Cash = db.T_CashBack.Find(id);
                if (MOD_Cash == null)
                {
                    return(Json("找不到该记录", JsonRequestBehavior.AllowGet));
                }
                int _Method = int.Parse(MOD_Cash.Method.ToString());       //当前审核方法
                int _Step   = int.Parse(MOD_Cash.Step.ToString());         //当前审核步骤
                T_CashBackApprove cur_Approve = db.T_CashBackApprove.FirstOrDefault(a => a.Oid == id && a.ApproveTime == null);
                if (cur_Approve == null)
                {
                    return(Json("该记录已审核", JsonRequestBehavior.AllowGet));
                }
                if (cur_Approve.ApproveName != curUser)
                {
                    return(Json("当前不是你审核,或者你的帐号在别处登录了", JsonRequestBehavior.AllowGet));
                }
                List <T_CashbackMethod> MOD_Method = db.T_CashbackMethod.Where(a => a.Method == _Method).ToList();
                int methodLength = MOD_Method.Count();  //该方法总步骤数
                //修改审核记录
                T_CashBackApprove MOD_Approve = db.T_CashBackApprove.FirstOrDefault(a => a.Oid == id && a.ApproveTime == null);
                MOD_Approve.Status      = status;
                MOD_Approve.Note        = memo;
                MOD_Approve.ApproveTime = DateTime.Now;
                db.Entry <T_CashBackApprove>(MOD_Approve).State = System.Data.EntityState.Modified;
                db.SaveChanges();
                //同意
                if (status == 1)
                {
                    //不是最后一步
                    if (_Step < methodLength - 1)
                    {
                        _Step++;                                                                                                            //步骤加1
                        T_CashbackMethod MOD_Nextapprove = db.T_CashbackMethod.FirstOrDefault(a => a.Method == _Method && a.Step == _Step); //当前流程的步骤
                        //审核同意而且,插入新的审核记录
                        T_CashBackApprove CashApprove = new T_CashBackApprove();
                        CashApprove.Oid         = id;
                        CashApprove.Note        = "";
                        CashApprove.Status      = -1;
                        CashApprove.ApproveName = MOD_Nextapprove.Name;
                        db.T_CashBackApprove.Add(CashApprove);
                        db.SaveChanges();
                        //主表状态为0 =>审核中
                        MOD_Cash.Status = 0;
                    }
                    else
                    {
                        //最后一步 修改主表的状态
                        MOD_Cash.Status = status;
                    }
                    //判断是否是出纳,出纳返现资金
                    if (cashier == 1)
                    {
                        //主表支出帐号
                        MOD_Cash.BackFrom = backfrom;
                        //修改订单
                        //查询是否还有该订单返现数据
                        //修改订单字段
                        //T_OrderList MOD_Order = db.T_OrderList.Find(MOD_Cash.OrderId);
                        //if (MOD_Order.Status_CashBack != 2)
                        //{
                        //    MOD_Order.Status_CashBack = 2;
                        //    db.Entry<T_OrderList>(MOD_Order).State = System.Data.EntityState.Modified;
                        //    int o = db.SaveChanges();
                        //    if (o == 0)
                        //    {
                        //        return Json("审核失败", JsonRequestBehavior.AllowGet);
                        //    }
                        //}
                    }
                }
                if (status == 2)
                {
                    //不同意
                    MOD_Cash.Status = status;
                    _Step           = 0;
                    //审核流程结束 申请人编辑后插入下一条记录
                    //驳回 发短信
                    T_User user = db.T_User.FirstOrDefault(a => a.Nickname == MOD_Cash.PostUser);
                    if (user != null)
                    {
                        if (!string.IsNullOrEmpty(user.Tel))
                        {
                            string[] msg = new string[] { "返现", "不同意" };
                            string   res = Lib.SendSMS.Send(msg, user.Tel);
                        }
                    }
                }

                MOD_Cash.Step = _Step;
                db.Entry <T_CashBack>(MOD_Cash).State = System.Data.EntityState.Modified;   //修改主表
                int    i      = db.SaveChanges();
                string result = "审核失败";
                if (i > 0)
                {
                    result = "审核成功";
                }
                List <T_ModularNotaudited> ModularNotaudited = db.T_ModularNotaudited.Where(a => a.ModularName == "返现").ToList();
                if (ModularNotaudited.Count > 0)
                {
                    foreach (var item in ModularNotaudited)
                    {
                        db.T_ModularNotaudited.Remove(item);
                    }
                    db.SaveChanges();
                }
                string         RetreatAppRoveSql   = "  select ApproveName as PendingAuditName,COUNT(*) as NotauditedNumber from T_CashBackApprove where  Oid in ( select ID from T_CashBack where For_Delete=0 and Status!=3 ) and  Status=-1 and ApproveTime is null GROUP BY ApproveName  ";
                List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList();
                string         Nickname            = Server.UrlDecode(Request.Cookies["Nickname"].Value);
                for (int e = 0; e < RetreatAppRoveQuery.Count; e++)
                {
                    string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;

                    T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "返现" && a.PendingAuditName == PendingAuditName);
                    if (NotauditedModel != null)
                    {
                        NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                        db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified;
                    }
                    else
                    {
                        T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                        ModularNotauditedModel.ModularName      = "返现";
                        ModularNotauditedModel.RejectNumber     = 0;
                        ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                        ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;
                        ModularNotauditedModel.ToupdateDate     = DateTime.Now; ModularNotauditedModel.ToupdateName = Nickname;
                        db.T_ModularNotaudited.Add(ModularNotauditedModel);
                    }
                    db.SaveChanges();
                }

                //增加驳回数据
                string         RejectNumberSql   = "select PostUser as PendingAuditName,COUNT(*) as NotauditedNumber from T_CashBack where Status='2' GROUP BY PostUser";
                List <Modular> RejectNumberQuery = db.Database.SqlQuery <Modular>(RejectNumberSql).ToList();

                for (int e = 0; e < RejectNumberQuery.Count; e++)
                {
                    //   string Name = RejectNumberQuery[e].PendingAuditName;
                    string PendingAuditName = RejectNumberQuery[e].PendingAuditName;


                    T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "返现" && a.PendingAuditName == PendingAuditName);
                    if (NotauditedModel != null)
                    {
                        NotauditedModel.RejectNumber = RejectNumberQuery[e].NotauditedNumber;
                        db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified;
                    }
                    else
                    {
                        T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                        ModularNotauditedModel.ModularName      = "返现";
                        ModularNotauditedModel.NotauditedNumber = 0;
                        ModularNotauditedModel.RejectNumber     = RejectNumberQuery[e].NotauditedNumber;
                        // string Name = RejectNumberQuery[e].PendingAuditName;
                        ModularNotauditedModel.PendingAuditName = PendingAuditName;
                        ModularNotauditedModel.ToupdateDate     = DateTime.Now;
                        ModularNotauditedModel.ToupdateName     = Nickname;
                        db.T_ModularNotaudited.Add(ModularNotauditedModel);
                    }
                    db.SaveChanges();
                }


                sc.Complete();
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 21
0
        //[Description("新增保存")]
        public JsonResult StockDetailAdd(T_StockStorage Model, string jsonStr, string CurUser)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                try
                {
                    string Nickname = "";
                    if (!string.IsNullOrWhiteSpace(CurUser))
                    {
                        Nickname = CurUser;
                    }
                    else
                    {
                        Nickname = Server.UrlDecode(Request.Cookies["Nickname"].Value);
                    }
                    Model.Type      = "入库";
                    Model.ApplyName = Nickname;
                    Model.ApplyDate = DateTime.Now;
                    db.T_StockStorage.Add(Model);
                    db.SaveChanges();
                    List <T_StockDetail> details = App_Code.Com.Deserialize <T_StockDetail>(jsonStr);


                    foreach (var item in details)
                    {
                        item.Oid = Model.ID;
                        db.T_StockDetail.Add(item);
                        db.SaveChanges();
                        string  code          = item.Code;
                        string  WarehouseCode = Model.WarehouseCode;
                        T_Stock Smodel        = db.T_Stock.SingleOrDefault(a => a.Code == code && a.WarehouseName == WarehouseCode);
                        if (Smodel != null)
                        {
                            Smodel.Qty += item.Qty;
                            db.Entry <T_Stock>(Smodel).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                        else
                        {
                            T_Stock StModel = new T_Stock();
                            StModel.Qty           = item.Qty;
                            StModel.Name          = item.Name;
                            StModel.Code          = item.Code;
                            StModel.WarehouseName = WarehouseCode;
                            db.T_Stock.Add(StModel);
                            db.SaveChanges();
                        }

                        T_StockOutstorage StorageModel = new T_StockOutstorage();
                        StorageModel.Code          = item.Code;
                        StorageModel.Name          = item.Name;
                        StorageModel.WarehouseCode = WarehouseCode;
                        StorageModel.number        = Model.ID.ToString();
                        StorageModel.Qty           = item.Qty;
                        StorageModel.Type          = "入库";
                        db.T_StockOutstorage.Add(StorageModel);
                        db.SaveChanges();
                    }
                    string cpcode = "";
                    for (int z = 0; z < details.Count; z++)
                    {
                        if (z == details.Count - 1)
                        {
                            cpcode += "{\"barcode\":\"" + details[z].Code + "\",\"qty\":" + details[z].Qty + "}";
                        }
                        else
                        {
                            cpcode += "{\"barcode\":\"" + details[z].Code + "\",\"qty\":" + details[z].Qty + "},";
                        }
                    }
                    EBMS.App_Code.GY gy  = new App_Code.GY();
                    string           cmd = "";
                    cmd = "{" +
                          "\"appkey\":\"171736\"," +
                          "\"method\":\"gy.erp.new.purchase.arrive.add\"," +
                          "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," +
                          "\"warehouse_code\":\"" + Model.WarehouseCode + "\"," +
                          "\"supplier_code\":\"" + Model.SupplierName + "\"," +
                          "\"order_type\":\"001\"," +
                          "\"detail_list\":[" + cpcode + "]" +
                          "}";
                    string sign    = gy.Sign(cmd);
                    string comcode = "";
                    comcode = "{" +
                              "\"appkey\":\"171736\"," +
                              "\"method\":\"gy.erp.new.purchase.arrive.add\"," +
                              "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"," +
                              "\"sign\":\"" + sign + "\"," +
                              "\"warehouse_code\":\"" + Model.WarehouseCode + "\"," +
                              "\"supplier_code\":\"" + Model.SupplierName + "\"," +
                              "\"order_type\":\"001\"," +
                              "\"detail_list\":[" + cpcode + "]" +
                              "}";
                    string   ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", comcode);
                    JsonData jsonData = null;
                    jsonData = JsonMapper.ToObject(ret);

                    if (jsonData.Count == 6)
                    {
                        return(Json(new { State = "Faile", Message = "写入管易失败,请联系管理员" }, JsonRequestBehavior.AllowGet));
                    }
                    else
                    {
                        sc.Complete();
                        return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                    }
                }
                catch (Exception ex)
                {
                    return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Esempio n. 22
0
        public JsonResult Check(string UserName, int approveID, int status, string memo)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                try
                {
                    int TotalStep            = db.T_ReissueConfig.ToList().Count;
                    T_ReissueApprove approve = db.T_ReissueApprove.Find(approveID);
                    string           name    = approve.ApproveName;
                    T_Reissue        model   = db.T_Reissue.Find(approve.Pid);
                    approve.ApproveName   = UserName;
                    approve.ApproveStatus = status;
                    approve.ApproveTime   = DateTime.Now;
                    approve.Memo          = memo;
                    model.Status          = status;
                    db.SaveChanges();
                    if (status == 2)//不同意
                    {
                        model.Step = model.Step + 1;
                        db.SaveChanges();
                    }
                    else//同意
                    {
                        int type     = db.T_ReissueReson.SingleOrDefault(s => s.Reson.Equals(model.ReissueReson)).Type;
                        int LastStep = db.T_ReissueConfig.OrderByDescending(s => s.Step).FirstOrDefault(s => s.Reson == type).Step;
                        if (LastStep > model.Step)//判断是否存在下一级
                        {
                            //获得下一级审核部门
                            string           nextapproveType = db.T_ReissueConfig.OrderBy(s => s.Step).FirstOrDefault(s => s.Reson == type && s.Step > model.Step).ApproveType;
                            T_ReissueApprove newApprove      = new T_ReissueApprove();
                            newApprove.ApproveStatus = -1;
                            newApprove.ApproveName   = nextapproveType;
                            newApprove.ApproveTime   = null;
                            newApprove.Pid           = approve.Pid;
                            db.T_ReissueApprove.Add(newApprove);
                            db.SaveChanges();
                            model.Status = 0;
                            model.Step   = model.Step + 1;
                            db.SaveChanges();
                        }
                        if (name.Equals("售后主管") || name.Equals("呼吸机主管"))//售后主管审核后直接加入补发货
                        {
                            //T_OrderList order = db.T_OrderList.Find(model.OrderId);

                            //List<T_Reissue> reissue = db.T_Reissue.Where(s => s.OrderCode.Equals(model.OrderCode) && s.IsDelete == 0).ToList();
                            ////判断是否为第一次补发
                            //if (reissue.Count() == 1)
                            //{
                            //    order.ReissueStatus = 2;
                            //}
                            //List<T_ReissueDetail> reiDetails = db.T_ReissueDetail.Where(s => s.ReissueId == model.ID).ToList();
                            //foreach (var item in reiDetails)
                            //{
                            //    T_OrderDetail Orderdetail = db.T_OrderDetail.FirstOrDefault(s => s.oid.Equals(order.code) && s.item_code.Equals(item.ProductCode));
                            //    if (Orderdetail != null)
                            //    {
                            //        Orderdetail.ReissueStatus = 1;
                            //        Orderdetail.ReissueQty += item.Num;
                            //    }
                            //}
                            db.SaveChanges();
                            #region 加入快递赔付

                            if (model.ReissueReson.Equals("快递破损"))
                            {
                                GY     gy  = new GY();
                                string cmd = "";

                                cmd = "{" +
                                      "\"appkey\":\"171736\"," +
                                      "\"method\":\"gy.erp.trade.get\"," +
                                      "\"page_no\":1," +
                                      "\"page_size\":10," +
                                      "\"platform_code\":\"" + model.OrderCode + "\"," +
                                      "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                                      "}";

                                string sign = gy.Sign(cmd);
                                cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                                string   ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                                JsonData jsonData = null;
                                jsonData = JsonMapper.ToObject(ret);

                                if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                                {
                                    cmd = "{" +
                                          "\"appkey\":\"171736\"," +
                                          "\"method\":\"gy.erp.trade.history.get\"," +
                                          "\"page_no\":1," +
                                          "\"page_size\":10," +
                                          "\"platform_code\":\"" + model.OrderCode + "\"," +
                                          "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                                          "}";
                                    sign     = gy.Sign(cmd);
                                    cmd      = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                                    ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                                    jsonData = null;
                                    jsonData = JsonMapper.ToObject(ret);
                                    if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                                    {
                                        return(Json(new { State = "Faile", Message = "订单号不存在" }));
                                    }
                                }
                                JsonData jsonOrders = jsonData["orders"][0];
                                var      deliver    = jsonOrders["deliverys"][0];
                                //快递单号
                                string mail_no = isNULL(deliver["mail_no"]).ToString();
                                //订单金额
                                string amount = isNULL(jsonOrders["amount"]).ToString();
                                //快递名称
                                string             express_name = isNULL(jsonOrders["express_name"]).ToString();
                                T_ExpressIndemnity Inde         = new T_ExpressIndemnity
                                {
                                    PostUserName       = model.PostUser,
                                    Date               = DateTime.Now,
                                    OrderNum           = model.OrderCode,
                                    wangwang           = model.VipCode,
                                    ShopName           = model.StoreName,
                                    RetreatExpressNum  = mail_no,
                                    State              = "0",
                                    OrderMoney         = Convert.ToDouble(amount),
                                    Type               = "破损",
                                    Second             = "0",
                                    CurrentApproveName = "快递组",
                                    IsDelete           = 0,
                                    ExpressName        = express_name,
                                    IndemnityMoney     = 0
                                };
                                db.T_ExpressIndemnity.Add(Inde);
                                db.SaveChanges();
                                List <T_ReissuePic> picList = db.T_ReissuePic.Where(s => s.ReissueId == model.ID).ToList();
                                foreach (var item in picList)
                                {
                                    T_ExpressIndemnityPic expressPic = new T_ExpressIndemnityPic
                                    {
                                        EID    = Inde.ID,
                                        PicURL = item.Url
                                    };
                                    db.T_ExpressIndemnityPic.Add(expressPic);
                                }
                                db.SaveChanges();
                            }
                            else if (model.ReissueReson.Equals("丢件"))
                            {
                                GY     gy  = new GY();
                                string cmd = "";

                                cmd = "{" +
                                      "\"appkey\":\"171736\"," +
                                      "\"method\":\"gy.erp.trade.get\"," +
                                      "\"page_no\":1," +
                                      "\"page_size\":10," +
                                      "\"platform_code\":\"" + model.OrderCode + "\"," +
                                      "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                                      "}";

                                string sign = gy.Sign(cmd);
                                cmd = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                                string   ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                                JsonData jsonData = null;
                                jsonData = JsonMapper.ToObject(ret);

                                if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                                {
                                    cmd = "{" +
                                          "\"appkey\":\"171736\"," +
                                          "\"method\":\"gy.erp.trade.history.get\"," +
                                          "\"page_no\":1," +
                                          "\"page_size\":10," +
                                          "\"platform_code\":\"" + model.OrderCode + "\"," +
                                          "\"sessionkey\":\"f5885504d9c84d1d8146200a4841f4b7\"" +
                                          "}";
                                    sign     = gy.Sign(cmd);
                                    cmd      = cmd.Replace("}", ",\"sign\":\"" + sign + "\"}");
                                    ret      = gy.DoPost("http://api.guanyierp.com/rest/erp_open", cmd);
                                    jsonData = null;
                                    jsonData = JsonMapper.ToObject(ret);
                                    if (jsonData.Count == 6 || jsonData["orders"].Count == 0)
                                    {
                                        return(Json(new { State = "Faile", Message = "订单号不存在" }));
                                    }
                                }
                                JsonData jsonOrders = jsonData["orders"][0];
                                var      deliver    = jsonOrders["deliverys"][0];
                                //快递单号
                                string mail_no = isNULL(deliver["mail_no"]).ToString();
                                //订单金额
                                string amount = isNULL(jsonOrders["amount"]).ToString();
                                //快递名称
                                string             express_name = isNULL(jsonOrders["express_name"]).ToString();
                                T_ExpressIndemnity Inde         = new T_ExpressIndemnity
                                {
                                    PostUserName       = model.PostUser,
                                    Date               = DateTime.Now,
                                    OrderNum           = model.OrderCode,
                                    wangwang           = model.VipCode,
                                    ShopName           = model.StoreName,
                                    RetreatExpressNum  = mail_no,
                                    State              = "0",
                                    OrderMoney         = Convert.ToDouble(amount),
                                    Type               = "丢件",
                                    Second             = "0",
                                    CurrentApproveName = "快递组",
                                    IsDelete           = 0,
                                    ExpressName        = express_name,
                                    IndemnityMoney     = 0
                                };
                                db.T_ExpressIndemnity.Add(Inde);
                                db.SaveChanges();
                            }

                            #endregion

                            if (PostGy(model) != "True")
                            {
                                return(Json(new { State = "Faile", Message = "上传管易错误,请联系管理员" }, JsonRequestBehavior.AllowGet));
                            }
                        }
                    }

                    db.SaveChanges();
                    List <T_ModularNotaudited> ModularNotaudited = db.T_ModularNotaudited.Where(a => a.ModularName == "补发货未审核").ToList();
                    if (ModularNotaudited.Count > 0)
                    {
                        foreach (var item in ModularNotaudited)
                        {
                            db.T_ModularNotaudited.Remove(item);
                        }
                        db.SaveChanges();
                    }
                    string         RetreatAppRoveSql   = "select isnull(ApproveUser,ApproveName) as PendingAuditName,COUNT(*) as NotauditedNumber from T_ReissueApprove where  Pid in ( select ID from T_Reissue where IsDelete=0 ) and  ApproveStatus=-1 and ApproveTime is null GROUP BY ApproveName,ApproveUser  ";
                    List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList();
                    string         Nickname            = Server.UrlDecode(Request.Cookies["Nickname"].Value);
                    for (int e = 0; e < RetreatAppRoveQuery.Count; e++)
                    {
                        string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;

                        T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "补发货未审核" && a.PendingAuditName == PendingAuditName);
                        if (NotauditedModel != null)
                        {
                            NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                            db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified;
                        }
                        else
                        {
                            T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                            ModularNotauditedModel.ModularName      = "补发货未审核";
                            ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                            ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;
                            ModularNotauditedModel.ToupdateDate     = DateTime.Now; ModularNotauditedModel.ToupdateName = Nickname;
                            db.T_ModularNotaudited.Add(ModularNotauditedModel);
                        }
                        db.SaveChanges();
                    }
                    sc.Complete();
                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception ex)
                {
                    return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }
Esempio n. 23
0
        public JsonResult Check(int id, int approveId, int status, string memo, string companyOut, string paymentBank, string paymentNumber, string CurUser)
        {
            T_User MOD_User = db.T_User.FirstOrDefault(a => a.Nickname == CurUser);
            //真名
            string name    = MOD_User.Name;
            var    Approve = db.T_FundApprove.Find(approveId);
            var    fund    = db.T_FundAllot.FirstOrDefault(s => s.ID == Approve.ItemId);
            int    step    = fund.Step;

            var configNextModel = db.T_FundConfig.FirstOrDefault(s => s.Step > step);


            Approve.ApproveTime = DateTime.Now;
            Approve.Memo        = memo;
            try
            {
                //同意
                if (status == 1)
                {
                    Approve.Status = 1;
                    //是否存在下一级
                    if (configNextModel != null)
                    {
                        fund.Step   = configNextModel.Step;
                        fund.Status = 0;
                        var approveModel = new T_FundApprove();
                        approveModel.ApproveName = configNextModel.ApproveUser;
                        approveModel.Status      = -1;
                        approveModel.ItemId      = fund.ID;
                        db.T_FundApprove.Add(approveModel);
                    }
                    else
                    {
                        fund.Status         = 1;
                        fund.CompanyOut     = companyOut;
                        fund.ThePaymentBank = paymentBank;
                        fund.PaymentNumber  = paymentNumber;
                        var time = DateTime.Now;
                        //调入记录
                        T_FundRecord modelIn = new T_FundRecord
                        {
                            Type     = "资金调入",
                            Number   = fund.FundAllotCode,
                            ShopName = fund.CompanyIn,
                            Account  = fund.AccountNumber,
                            Cost     = Convert.ToDecimal(fund.theMoney),
                            Time     = time
                        };
                        db.T_FundRecord.Add(modelIn);
                        //调出记录
                        T_FundRecord modelOut = new T_FundRecord
                        {
                            Type     = "资金调出",
                            Number   = fund.FundAllotCode,
                            ShopName = fund.CompanyOut,
                            Account  = fund.PaymentNumber,
                            Cost     = Convert.ToDecimal("-" + fund.theMoney),
                            Time     = time
                        };
                        db.T_FundRecord.Add(modelOut);
                    }
                }
                //不同意
                else
                {
                    Approve.Status = 2;
                    fund.Status    = 2;
                    fund.Step      = db.T_FundConfig.OrderBy(s => s.Step).First().Step;
                }


                var i = db.SaveChanges();


                string         RetreatAppRoveSql   = " select ApproveName as PendingAuditName,COUNT(*) as NotauditedNumber from T_FundApprove where  ItemId in ( select id from T_FundAllot where IsDelete=0) and  Status=-1 and ApproveTime is null GROUP BY ApproveName ";
                List <Modular> RetreatAppRoveQuery = db.Database.SqlQuery <Modular>(RetreatAppRoveSql).ToList();
                string         Nickname            = CurUser;
                for (int e = 0; e < RetreatAppRoveQuery.Count; e++)
                {
                    string PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;

                    T_ModularNotaudited NotauditedModel = db.T_ModularNotaudited.SingleOrDefault(a => a.ModularName == "资金调拨未审核" && a.PendingAuditName == PendingAuditName);
                    if (NotauditedModel != null)
                    {
                        NotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                        db.Entry <T_ModularNotaudited>(NotauditedModel).State = System.Data.EntityState.Modified;
                    }
                    else
                    {
                        T_ModularNotaudited ModularNotauditedModel = new T_ModularNotaudited();
                        ModularNotauditedModel.ModularName      = "资金调拨未审核";
                        ModularNotauditedModel.NotauditedNumber = RetreatAppRoveQuery[e].NotauditedNumber;
                        ModularNotauditedModel.PendingAuditName = RetreatAppRoveQuery[e].PendingAuditName;
                        ModularNotauditedModel.ToupdateDate     = DateTime.Now; ModularNotauditedModel.ToupdateName = Nickname;
                        db.T_ModularNotaudited.Add(ModularNotauditedModel);
                    }
                    db.SaveChanges();
                }

                if (i > 0)
                {
                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    return(Json(new { State = "Faile", Message = "操作失败" }, JsonRequestBehavior.AllowGet));
                }
            }
            catch (Exception ex)
            {
                return(Json(new { State = "Faile", Message = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 24
0
        public JsonResult SupplierEditSave(T_Suppliers model)
        {
            T_Suppliers editModel = db.T_Suppliers.Find(model.ID);

            editModel.SuppliersName                 = model.SuppliersName;
            editModel.ContactName                   = model.ContactName;
            editModel.ContactiTelephone             = model.ContactiTelephone;
            db.Entry <T_Suppliers>(editModel).State = System.Data.Entity.EntityState.Modified;
            try
            {
                db.SaveChanges();
                return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
            }
            catch (DbEntityValidationException ex)
            {
                return(Json(new { State = "Faile", Message = ex.EntityValidationErrors.First().ValidationErrors.First().ErrorMessage }, JsonRequestBehavior.AllowGet));
            }
        }
Esempio n. 25
0
        public JsonResult Save(T_Deliver model, string jsonStr, string CurUser, string TiaoMa, string type)
        {
            using (TransactionScope sc = new TransactionScope())
            {
                try {
                    // 查询发货表 订单是否发货
                    T_Deliver deliverFlag = db.T_Deliver.FirstOrDefault(a => a.MailNo == model.MailNo);
                    if (deliverFlag != null)
                    {
                        return(Json(new { State = "Faile", Message = "该单据编号已经发货" }, JsonRequestBehavior.AllowGet));
                    }
                    T_Warehouses warehouseMod = db.T_Warehouses.SingleOrDefault(a => a.name == model.WarehouseCode);
                    //发货记录表增加发货记录
                    string curUser = "";
                    if (!string.IsNullOrWhiteSpace(CurUser))
                    {
                        curUser = CurUser;
                    }
                    else
                    {
                        curUser = Server.UrlDecode(Request.Cookies["NickName"].Value);
                    }

                    string    IP  = Request.UserHostAddress;
                    T_Deliver MOD = new T_Deliver();
                    MOD.PostTime      = DateTime.Now;
                    MOD.PostName      = curUser;
                    MOD.OrderNum      = model.OrderNum;
                    MOD.MailNo        = model.MailNo;
                    MOD.WarehouseCode = warehouseMod.code;
                    MOD.IP            = IP;
                    MOD.Note          = model.Note;
                    db.T_Deliver.Add(MOD);
                    db.SaveChanges();

                    /*
                     * 解析jsonStr
                     * 修改库存表发货详情记录表
                     * 库存表是否有该商品的库存信息?直接修改库存数量:新增一条库存信息qty为负数
                     */
                    List <AddMod> detail = Com.Deserialize <AddMod>(jsonStr);

                    if (type == "1")
                    {
                        List <TiaoMaAddMod> TiaoMaAddModList = new List <TiaoMaAddMod>();
                        string[]            tiaomaList       = TiaoMa.Split('\n');
                        int Qty = 0;

                        for (int i = 0; i < detail.Count; i++)
                        {
                            Qty += int.Parse(detail[i].qty.ToString());
                            int tiaomalistQty = 0;
                            int detailcount   = int.Parse(detail[i].qty.ToString());
                            for (int z = 0; z < tiaomaList.Length; z++)
                            {
                                if (tiaomaList[z] == "")
                                {
                                    break;
                                }

                                string tiaomazz = "";
                                //if (z == tiaomaList.Length - 1)
                                //{
                                //     tiaomazz = tiaomaList[z].Substring(0, tiaomaList[z].Length);

                                //}
                                //else
                                //{
                                //     tiaomazz = tiaomaList[z].Substring(0, tiaomaList[z].Length - 1);
                                //}
                                tiaomazz = tiaomaList[z].Substring(0, tiaomaList[z].Length - 1);
                                if (detail[i].tiaoma == tiaomazz)
                                {
                                    tiaomalistQty++;
                                }
                            }
                            if (detailcount != tiaomalistQty)
                            {
                                TiaoMaAddMod TiaoMaAddModModel = new TiaoMaAddMod();
                                TiaoMaAddModModel.tiaoma = detail[i].tiaoma;
                                TiaoMaAddModList.Add(TiaoMaAddModModel);
                            }
                        }



                        if (TiaoMaAddModList.Count > 0)
                        {
                            string nottiaoma = "";
                            for (int i = 0; i < TiaoMaAddModList.Count; i++)
                            {
                                if (i == TiaoMaAddModList.Count - 1)
                                {
                                    nottiaoma += TiaoMaAddModList[i].tiaoma;
                                }
                                else
                                {
                                    nottiaoma += TiaoMaAddModList[i].tiaoma + ",";
                                }
                            }
                            return(Json(new { State = "Faile", Message = "该" + nottiaoma + "数量与详情不符合", stype = "0" }, JsonRequestBehavior.AllowGet));
                        }
                        int tiaomaQty = 0;
                        for (int i = 0; i < tiaomaList.Length; i++)
                        {
                            if (tiaomaList[i] != "")
                            {
                                tiaomaQty++;
                            }
                        }
                        if (Qty != tiaomaQty)
                        {
                            return(Json(new { State = "Faile", Message = "存在多发货物", stype = "0" }, JsonRequestBehavior.AllowGet));
                        }
                    }

                    for (int i = 0; i < detail.Count; i++)
                    {
                        //操作库存表
                        string  _code   = detail[i].item_code;
                        T_Stock StocMOD = db.T_Stock.SingleOrDefault(a => a.Code == _code);
                        if (StocMOD != null)
                        {
                            int _qty = int.Parse(detail[i].qty.ToString());
                            StocMOD.Qty -= _qty;
                            db.Entry <T_Stock>(StocMOD).State = System.Data.Entity.EntityState.Modified;
                            db.SaveChanges();
                        }
                        else
                        {
                            T_Stock createMod = new T_Stock();
                            createMod.Name          = detail[i].item_name;
                            createMod.Code          = detail[i].item_code;
                            createMod.Qty           = -int.Parse(detail[i].qty.ToString());
                            createMod.WarehouseName = warehouseMod.code;
                            db.T_Stock.Add(createMod);
                            db.SaveChanges();
                        }
                        //操作发货详情记录表
                        T_DeliverDetail detailMOD = new T_DeliverDetail();
                        detailMOD.Code = detail[i].item_code;
                        detailMOD.Name = detail[i].item_name;
                        detailMOD.Qty  = detail[i].qty;
                        detailMOD.Oid  = MOD.ID;
                        db.T_DeliverDetail.Add(detailMOD);
                        db.SaveChanges();


                        T_StockOutstorage StorageModel = new T_StockOutstorage();
                        StorageModel.Code          = detail[i].item_code;
                        StorageModel.Name          = detail[i].item_name;
                        StorageModel.WarehouseCode = model.WarehouseCode;
                        StorageModel.number        = model.MailNo;
                        StorageModel.Qty           = detail[i].qty;
                        StorageModel.Type          = "出库";
                        db.T_StockOutstorage.Add(StorageModel);
                        db.SaveChanges();
                    }
                    sc.Complete();
                    return(Json(new { State = "Success" }, JsonRequestBehavior.AllowGet));
                }
                catch (Exception e)
                {
                    return(Json(new { State = "Faile", Message = e.Message }, JsonRequestBehavior.AllowGet));
                }
            }
        }