Ejemplo n.º 1
0
        // [ValidateAntiForgeryToken]
        public ActionResult SubmitForm(TemplateEntity templateEntity, string keyValue)
        {
            var num = 0;

            lock (_MyLock)
            {
                try
                {
                    if (Request.Files.Count > 0)
                    {
                        var file = Request.Files["TEM_IMG"];
                        if (!string.IsNullOrEmpty(file.FileName))
                        {
                            num = 1;
                            var fileName = file.FileName;
                            foreach (char invalidChar in Path.GetInvalidFileNameChars())
                            {
                                fileName = fileName.Replace(invalidChar.ToString(), "_");
                            }
                            fileName = fileName.Replace(" ", "");
                            var name = fileName.Remove(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
                            fileName = name + Path.GetExtension(fileName);
                            var filePath = Path.Combine(HttpContext.Server.MapPath("/Uploads/Template/"), fileName);
                            file.SaveAs(filePath);
                            templateEntity.TEM_IMG = fileName;
                        }
                        for (int i = num; i < Request.Files.Count; i++)
                        {
                            var file0 = Request.Files[i];
                            if (!string.IsNullOrEmpty(file0.FileName))
                            {
                                var fileName = file0.FileName;
                                foreach (char invalidChar in Path.GetInvalidFileNameChars())
                                {
                                    fileName = fileName.Replace(invalidChar.ToString(), "_");
                                }
                                fileName = fileName.Replace(" ", "");
                                var name = fileName.Remove(fileName.LastIndexOf("."), fileName.Length - fileName.LastIndexOf("."));
                                fileName = name + DateTime.Now.ToString("yyyyMMddHHmmss") + Path.GetExtension(fileName);
                                var filePath = Path.Combine(HttpContext.Server.MapPath("/Uploads/Template/"), fileName);
                                file0.SaveAs(filePath);
                                if (string.IsNullOrEmpty(templateEntity.DRAWING))
                                {
                                    templateEntity.DRAWING = fileName;
                                }
                                else
                                {
                                    templateEntity.DRAWING += "/" + fileName;
                                }
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(keyValue))
                    {
                        templateEntity.TEM_NO         = templateApp.ProduceNo();
                        templateEntity.BACK_TAG       = "F";
                        templateEntity.TEM_ACCEPT     = "D";
                        templateEntity.NOTICE_GET     = "F";
                        templateEntity.PRT_TAG        = "F";
                        templateEntity.PRT_IMG        = "F";
                        templateEntity.AUDIT_TAG      = "F";
                        templateEntity.CLOSE_ID       = "F";
                        templateEntity.RATIFY_TAG     = "T";
                        templateEntity.TEM_DEP        = templateEntity.RATIFY_MAN;
                        templateEntity.APP_DEP        = organizeApp.GetForm(OperatorProvider.Provider.GetCurrent().DepartmentId).F_FullName;
                        templateEntity.CREATE_USER    = OperatorProvider.Provider.GetCurrent().UserName;
                        templateEntity.CREATE_DATE    = DateTime.Now;
                        templateEntity.RATIFY_DATE    = templateEntity.CREATE_DATE;
                        templateEntity.CREATE_USER_ID = OperatorProvider.Provider.GetCurrent().UserCode;
                        templateEntity.TEM_IMG        = templateEntity.TEM_IMG;
                        templateApp.SubmitForm(templateEntity);
                        var AUDIT_MAN = userApp.GetFormByName(templateEntity.AUDIT_MAN);
                        if (!string.IsNullOrEmpty(AUDIT_MAN.F_Email))
                        {
                            mHelper.MailServer = "10.110.120.2";
                            mHelper.Send(AUDIT_MAN.F_Email, "打样审核", "你好," + templateEntity.CREATE_USER + "有打样申请需要你登录OA去做批准,请点击链接<a>http://10.110.120.6:8090/</a>");
                        }
                    }
                    else
                    {
                        var temp = templateApp.GetForm(keyValue);
                        if (temp.AUDIT_MAN != templateEntity.AUDIT_MAN)
                        {
                            var AUDIT_MAN = userApp.GetFormByName(templateEntity.AUDIT_MAN);
                            if (!string.IsNullOrEmpty(AUDIT_MAN.F_Email))
                            {
                                mHelper.MailServer = "10.110.120.2";
                                mHelper.Send(AUDIT_MAN.F_Email, "打样审核", "你好," + templateEntity.CREATE_USER + "有打样申请需要你登录OA去做批准,请点击链接<a>http://10.110.120.6:8090/</a>");
                            }
                        }
                        temp.TEM_NAME      = templateEntity.TEM_NAME;
                        temp.CUSTOMER      = templateEntity.CUSTOMER;
                        temp.TEM_TYPE      = templateEntity.TEM_TYPE;
                        temp.TEM_NUM       = templateEntity.TEM_NUM;
                        temp.MAT_REQ       = templateEntity.MAT_REQ;
                        temp.AUDIT_MAN     = templateEntity.AUDIT_MAN;
                        temp.PROCESS       = templateEntity.PROCESS;
                        temp.HOPE_DD       = templateEntity.HOPE_DD;
                        temp.DRAWING       = templateEntity.DRAWING;
                        temp.DRAWING_ALIAS = templateEntity.DRAWING_ALIAS;
                        temp.TEM_IMG       = templateEntity.TEM_IMG;
                        temp.DRAWING       = templateEntity.DRAWING;
                        temp.RATIFY_MAN    = templateEntity.RATIFY_MAN;
                        temp.TEM_CHARGE    = templateEntity.TEM_CHARGE;
                        temp.SIZE          = templateEntity.SIZE;
                        temp.TEM_REMARK    = templateEntity.TEM_REMARK;
                        templateApp.SubmitForm(temp, keyValue);
                    }
                }
                catch (Exception ex)
                {
                    new ErrorLogApp().SubmitForm(ex);
                }
            }
            return(Success("操作成功!"));
        }
Ejemplo n.º 2
0
        public ActionResult SubmitForm(ApplyBillEntity applyBillEntity, int?keyValue)
        {
            try
            {
                var        userId      = OperatorProvider.Provider.GetCurrent().UserId;
                var        roleId      = OperatorProvider.Provider.GetCurrent().RoleId;
                var        role        = new RoleApp().GetForm(roleId);
                var        appMan      = userApp.GetForm(userId);
                UserEntity firstExaMan = null;
                if (applyBillEntity != null)
                {
                    if (Request.Files.Count > 0)
                    {
                        var file = Request.Files[0];
                        if (!string.IsNullOrEmpty(file.FileName))
                        {
                            var fileName = file.FileName;
                            foreach (char invalidChar in Path.GetInvalidFileNameChars())
                            {
                                fileName = fileName.Replace(invalidChar.ToString(), "_");
                            }
                            fileName = fileName.Replace(" ", "");
                            var filePath = Path.Combine(HttpContext.Server.MapPath("/Uploads/"), fileName);
                            file.SaveAs(filePath);
                            applyBillEntity.annex = fileName;
                        }
                    }
                    if (keyValue != null)//修改
                    {
                        var apply    = applyBillApp.GetForm(keyValue.Value);
                        var userName = OperatorProvider.Provider.GetCurrent().UserName;
                        if (!apply.appMan.Equals(userName))
                        {
                            return(Error("非本人不能修改申购单。"));
                        }
                        if (apply.appExaTag == "T")
                        {
                            return(Error("该申购单已审核,不能修改。"));
                        }
                        if (apply.appExaTag == "F" || apply.appExaMan == null)
                        {
                            apply.appExaTag = "M";
                        }

                        apply.appExaDate = null;
                        apply.appExaIdea = null;
                        apply.backReason = null;
                        apply.prdName    = applyBillEntity.prdName;
                        apply.spc        = applyBillEntity.spc;
                        apply.rem        = applyBillEntity.rem;
                        apply.useGroup   = applyBillEntity.useGroup;
                        apply.viceNum    = applyBillEntity.viceNum;
                        apply.annex      = applyBillEntity.annex;
                        apply.TypeID     = applyBillEntity.TypeID;
                        if (!string.IsNullOrEmpty(applyBillEntity.viceUnit))
                        {
                            apply.viceUnit = applyBillEntity.viceUnit.Trim().ToUpper();
                        }
                        apply.appNum   = applyBillEntity.appNum;
                        apply.appUnit  = applyBillEntity.appUnit.Trim().ToUpper();
                        apply.purIsTem = applyBillEntity.purIsTem;
                        apply.WAREWAY  = applyBillEntity.WAREWAY;
                        apply.hopeDD   = applyBillEntity.hopeDD;
                        apply.mat      = applyBillEntity.mat;
                        apply.orderNo  = applyBillEntity.orderNo;
                        if (apply.appExaMan != applyBillEntity.appExaMan)
                        {
                            apply.appExaMan = applyBillEntity.appExaMan;
                            var appExaMan = userApp.GetFormByName(applyBillEntity.appExaMan);
                            if (!string.IsNullOrEmpty(appExaMan.F_Email))
                            {
                                mHelper.MailServer = "10.110.120.2";
                                mHelper.Send(appExaMan.F_Email, "申购单审核", "你好," + appMan.F_RealName + "有申购单需要你登录OA去做审核,请点击链接<a>http://10.110.120.6:8090/</a>");
                            }
                        }
                        apply.appAuthMan = applyBillEntity.appAuthMan;
                        applyBillApp.SubmitForm(apply, keyValue);
                    }
                    else
                    {
                        applyBillEntity.appUnit = applyBillEntity.appUnit.Trim().ToUpper();
                        if (!string.IsNullOrEmpty(applyBillEntity.viceUnit))
                        {
                            applyBillEntity.viceUnit = applyBillEntity.viceUnit.Trim().ToUpper();
                        }
                        applyBillEntity.appAuthTag = "D";
                        if (role != null)
                        {
                            if (role.F_FullName.Equals("工程师"))
                            {
                                applyBillEntity.appExaTag = "A";
                                firstExaMan = userApp.GetForm(appMan.F_ManagerId);
                                applyBillEntity.FirstExaMan = firstExaMan.F_RealName;
                            }
                            else
                            {
                                applyBillEntity.appExaTag = "D";
                            }
                        }

                        applyBillEntity.purAuthTag = "D";
                        applyBillEntity.purExaTag  = "D";
                        applyBillEntity.prtTag     = "F";
                        applyBillEntity.caseTag    = "F";
                        applyBillEntity.isPreMoney = "N";
                        if (applyBillEntity.purIsTem == null)
                        {
                            applyBillEntity.purIsTem = "F";
                        }
                        var appExaMan    = userApp.GetFormByName(applyBillEntity.appExaMan);
                        var appManDepart = organizeApp.GetForm(appMan.F_DepartmentId);
                        applyBillEntity.appMan = appMan.F_RealName;
                        applyBillEntity.appDep = appManDepart.F_FullName;
                        applyBillEntity.date   = DateTime.Now;
                        applyBillApp.SubmitForm(applyBillEntity, keyValue);
                        if (role != null && !role.F_FullName.Equals("工程师"))
                        {
                            if (!string.IsNullOrEmpty(appExaMan.F_Email))
                            {
                                mHelper.MailServer = "10.110.120.2";
                                mHelper.Send(appExaMan.F_Email, "申购单审核", "你好," + appMan.F_RealName + "有申购单需要你登录OA去做审核,请点击链接<a>http://10.110.120.6:8090/</a>");
                            }
                        }
                        else
                        {
                            if (!string.IsNullOrEmpty(firstExaMan.F_Email))
                            {
                                mHelper.MailServer = "10.110.120.2";
                                mHelper.Send(firstExaMan.F_Email, "申购单初审", "你好," + firstExaMan.F_RealName + "有申购单需要你登录OA去做审核,请点击链接<a>http://10.110.120.6:8090/</a>");
                            }
                        }
                    }
                    return(Success("操作成功。"));
                }
            }
            catch (Exception ex)
            {
                new ErrorLogApp().SubmitForm(ex);
                return(Error("操作失败。"));
            }
            return(Success("操作成功。"));
        }
Ejemplo n.º 3
0
        public ActionResult SubmitForm(ApplyBillEntity applyBillEntity, int?keyValue, string code)
        {
            ApplyBillEntity apply    = null;
            var             userName = OperatorProvider.Provider.GetCurrent().UserName;

            apply = applyBillApp.GetForm(keyValue.Value);
            var price = priceApp.GetFormJson(applyBillEntity.priNO);

            if (!string.IsNullOrEmpty(code))//转厂
            {
                ApplyBillEntity apply1    = new ApplyBillEntity();
                var             applyBill = applyBillApp.GetForm(keyValue.Value);
                apply1.purNo       = applyBillApp.ProducePurNO(applyBillEntity.purSup, price.currency.Value);
                apply1.appExaTag   = applyBill.appExaTag;
                apply1.appExaDate  = applyBill.appExaDate;
                apply1.appExaIdea  = applyBill.appExaIdea;
                apply1.appExaMan   = applyBill.appExaMan;
                apply1.appAuthTag  = applyBill.appAuthTag;
                apply1.appAuthDate = applyBill.appAuthDate;
                apply1.appAuthMan  = applyBill.appAuthMan;
                apply1.appAuthIdea = applyBill.appAuthIdea;
                apply1.prdName     = applyBill.prdName;
                apply1.spc         = applyBill.spc;
                apply1.rem         = applyBill.rem;
                apply1.prdNo       = applyBill.prdNo;
                apply1.useGroup    = applyBill.useGroup;
                apply1.viceNum     = applyBill.viceNum;
                apply1.viceUnit    = applyBill.viceUnit;
                apply1.appNum      = (applyBill.appNum ?? 0) - (applyBill.yiJiaoNum ?? 0);
                apply1.appUnit     = applyBill.appUnit;
                apply1.purIsTem    = applyBill.purIsTem;
                apply1.WAREWAY     = applyBill.WAREWAY;
                apply1.hopeDD      = applyBill.hopeDD;
                apply1.mat         = applyBill.mat;
                apply1.orderNo     = applyBill.orderNo;
                apply1.appMan      = applyBill.appMan;
                apply1.appDep      = applyBill.appDep;
                apply1.date        = applyBill.date;
                apply1.isPreMoney  = "N";
                apply1.prtTag      = "F";
                apply1.caseTag     = "F";
                apply1.purWay      = 0;
                apply1.purAuthTag  = "D";
                apply1.purExaTag   = "D";
                apply1.purDD       = DateTime.Now;
                apply1.purExaMan   = applyBillEntity.purExaMan;
                apply1.purAuthMan  = applyBillEntity.purAuthMan;
                apply1.purSup      = applyBillEntity.purSup;
                apply1.purPrice    = applyBillEntity.purPrice;
                apply1.priNO       = applyBillEntity.priNO;
                apply1.purMan      = userName;
                apply1.priNO       = applyBillEntity.priNO;
                apply1.purExaDate  = null;
                apply1.purAuthDate = null;
                apply1.purAuthIdea = null;
                apply1.purExaIdea  = null;
                applyBillApp.SubmitForm(apply1);
                applyBill.caseTag = "T";//当前项结案
                applyBill.rem     = "转厂:" + apply1.purNo;
                applyBillApp.SubmitForm(applyBill, applyBill.ID);
                if (!string.IsNullOrEmpty(apply1.purExaMan))
                {
                    var purExaMan = userApp.GetFormByName(apply1.purExaMan);
                    mHelper.MailServer = "10.110.120.2";
                    if (!string.IsNullOrEmpty(purExaMan.F_Email))
                    {
                        mHelper.Send(purExaMan.F_Email, "采购单审核", "你好," + apply1.purMan + "有采购单需要你登录OA去做审核,请点击链接<a>http://10.110.120.6:8090/</a>");
                    }
                }
            }
            else  //转单
            {
                apply.purNo       = applyBillApp.ProducePurNO(applyBillEntity.purSup, price.currency.Value);
                apply.purDD       = DateTime.Now;
                apply.purExaMan   = applyBillEntity.purExaMan;
                apply.purAuthMan  = applyBillEntity.purAuthMan;
                apply.purSup      = applyBillEntity.purSup;
                apply.purPrice    = applyBillEntity.purPrice;
                apply.priNO       = applyBillEntity.priNO;
                apply.purMan      = userName;
                apply.priNO       = applyBillEntity.priNO;
                apply.purExaDate  = null;
                apply.purAuthDate = null;
                apply.purAuthIdea = null;
                apply.purExaIdea  = null;
                if (apply.purExaTag != "D")
                {
                    apply.purExaTag = "M";
                }
                if (apply.purAuthTag == "F")
                {
                    apply.purAuthTag = "M";
                }
                applyBillApp.SubmitForm(apply, keyValue);//转单
                if (!string.IsNullOrEmpty(apply.purExaMan))
                {
                    var purExaMan = userApp.GetFormByName(apply.purExaMan);
                    mHelper.MailServer = "10.110.120.2";
                    if (!string.IsNullOrEmpty(purExaMan.F_Email))
                    {
                        mHelper.Send(purExaMan.F_Email, "采购单审核", "你好," + apply.purMan + "有采购单需要你登录OA去做审核,请点击链接<a>http://10.110.120.6:8090/</a>");
                    }
                }
            }


            return(Success("操作成功。"));
        }