Esempio n. 1
0
        public static string GenrateVVIRFQDetail(object data, string ActivityID, string PageType)
        {
            //所有需要显示的字段,从Field Mnager中读出
            List<FieldCategory> allGategory = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_VVI);

            StringBuilder sb = new StringBuilder();
            //将data实体的数据赋值到FIELD的DATAVALUE中
            if (data != null)
            {
                foreach (FieldCategory fc in allGategory)
                {
                    foreach (BI.SGP.BLL.DataModels.FieldInfo field in fc.Fields)
                    {
                        if (field.Enable == 1)
                        {
                            PropertyInfo propertyInfo = data.GetType().GetProperty(field.FieldName);
                            if (propertyInfo != null)
                            {
                                field.DataValue = propertyInfo.GetValue(data);
                            }
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(ActivityID))
            {
                BLL.Models.VVIRFQManager vvirfqDetail = data as BLL.Models.VVIRFQManager;
                WF.WFTemplate wf = new WF.WFTemplate("VVIWF", vvirfqDetail == null ? 0 : vvirfqDetail.ID);
                if (wf != null)
                {
                    if (wf.CurrentActivity != null)
                    {
                        ActivityID = wf.CurrentActivity.ID.ToString();
                    }
                    else
                    {
                        ActivityID = wf.FirstActivity.ID.ToString();
                    }
                }
            }

            int ID = 1;
            foreach (FieldCategory fc in allGategory)
            {
                string s = string.Empty;
                switch (PageType)
                {
                    case "edit":
                        s = GenrateCategory(ref ID, allGategory, fc, data, ActivityID);
                        break;
                }
                sb.AppendLine(s);
            }

            return sb.ToString();
        }
Esempio n. 2
0
        public static string GenrateModelforRFQVVIDetail(object data, string ActivityID)
        {
            //所有需要显示的字段,从Field Mnager中读出
            List<FieldCategory> allGategory = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_VVI);

            //如果传入的ACTIVITY ID为空,则找到当前步骤
            if (string.IsNullOrEmpty(ActivityID))
            {
                BLL.Models.RFQDetail rfqDetail = data as BLL.Models.RFQDetail;
                WF.WFTemplate wf = new WF.WFTemplate("DefaultWF", rfqDetail == null ? 0 : rfqDetail.RFQID);
                if (wf != null)
                {
                    if (wf.CurrentActivity != null)
                    {
                        ActivityID = wf.CurrentActivity.ID.ToString();
                    }
                    else
                    {
                        ActivityID = wf.FirstActivity.ID.ToString();
                    }
                }
            }

            List<string> fieldsJustDisplay = null;
            //初始化必填字段
            InitRequiredConfg(data, allGategory, out fieldsJustDisplay);

            StringBuilder sb = new StringBuilder();
            //将data实体的数据赋值到FIELD的DATAVALUE中
            if (data != null)
            {
                foreach (FieldCategory fc in allGategory)
                {
                    //if (currentRole != fc.AllowedRoles) continue;
                    foreach (BI.SGP.BLL.DataModels.FieldInfo field in fc.Fields)
                    {
                        if (field.Enable == 1)
                        {
                            PropertyInfo propertyInfo = data.GetType().GetProperty(field.FieldName);
                            if (propertyInfo != null)
                            {
                                field.DataValue = propertyInfo.GetValue(data);
                            }
                        }
                    }
                }
            }

            FieldCategory priceDetailCategroy = allGategory.Find(t => t.ID == "7");
            FieldCategory termsConditionsCategory = allGategory.Find(t => t.ID == "8");
            FieldCategory VVItermsConditionsCategory = allGategory.Find(t => t.ID == "9");

            int ID = 1;
            foreach (FieldCategory fc in allGategory)
            {
                if (fc.ID == "8" || fc.ID == "7" || fc.ID == "9")
                {
                    continue;
                }
                string s = GenrateCategory(ref ID, allGategory, fc, data, ActivityID, true);
                sb.AppendLine(s);

            }
            AccessServiceReference.Role[] role = BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Roles;

            sb.Append("<script>");

            if (!(role.Contains("SGP_BDMGAM") || role.Contains("SGP_Management") || role.Contains("SGP_RFQPrimaryContact")))
            {
                foreach (string fieldName in fieldsJustDisplay)
                {
                    sb.AppendFormat("$('#{0}').attr('disabled','disabled');", fieldName);
                }
            }

            sb.AppendLine("</script>");
            sb.AppendFormat("<script>$.rfqDetail.Init();</script>");
            return sb.ToString();
        }
Esempio n. 3
0
        /// <summary>
        /// 初始化必填字段
        /// </summary>
        /// <param name="data"></param>
        /// <param name="allGategory"></param>
        private static void InitRequiredConfg(object data, List<FieldCategory> allGategory, out List<string> fieldsJustDisplay)
        {
            fieldsJustDisplay = new List<string>();
            BI.SGP.BLL.Models.RFQDetail detail = data as BI.SGP.BLL.Models.RFQDetail;

            int rfqId = 0; if (detail != null) rfqId = detail.RFQID;
            WF.WFTemplate wf = new WF.WFTemplate("DefaultWF", rfqId);

            List<WF.WFActivityField> wfFields = null;
            if (wf.CurrentActivity != null)
            {
                wfFields = wf.CurrentActivity.GetCheckFields();
            }
            else
            {
                wfFields = wf.FirstActivity.GetCheckFields();
            }

            //取得必填项
            if (wfFields != null)
            {
                foreach (FieldCategory fc in allGategory)
                {
                    //if (currentRole != fc.AllowedRoles) continue;
                    foreach (BI.SGP.BLL.DataModels.FieldInfo field in fc.Fields)
                    {
                        PropertyInfo propertyInfo = data.GetType().GetProperty(field.FieldName);
                        if (propertyInfo != null)
                        {
                            WF.WFActivityField wfFld = wfFields.Find(t => t.FieldName.CompareTo(field.FieldName) == 0);
                            if (wfFld != null)
                            {
                                field.WFRequiredOption = wfFld.IsRequired == true ? RequiredOption.Required : RequiredOption.Optional;
                                //加入到仅仅需要显示的列表中
                            }
                        }
                        if (field.WFRequiredOption == RequiredOption.None) fieldsJustDisplay.Add(field.FieldName);
                    }
                }
            }
        }
Esempio n. 4
0
        public void SpecialSendMail(int EntityID,string VendorRFQNumber,string VendorCode)
        {
            string vendormail = "";
            try
            {
                WF.WFUser user = new WF.WFUser(VendorCode);
                if (user != null)
                {
                    vendormail = user.Email;
                }
                else
                {
                    vendormail = "*****@*****.**";
                }
            }
            catch
            {
                vendormail = "*****@*****.**";
            }

            BI.SGP.BLL.WF.WFTemplate wftemplate = new WF.WFTemplate("SUPPLIERWF", EntityID, VendorRFQNumber);
            BI.SGP.BLL.WF.WFActivity wfactivity = wftemplate.FirstActivity;
            BI.SGP.BLL.WF.Action.SendMailAction sendmail = new WF.Action.SendMailAction();
            sendmail.DoActionForVVI(wfactivity, VendorCode, vendormail);
        }
Esempio n. 5
0
        public SystemMessages AssignVVIData(int ID, string suppliercode, SystemMessages sysmgs)
        {
            this.ID = ID;
            //SystemMessages sysmgs = new SystemMessages();

            try
            {
                string strField = "", strValue = "";
                FieldInfoCollecton supplierfields = FieldCategory.GetAllFields(FieldCategory.Category_TYPE_SGPFORSUPPLIER);
                string number = "";
                foreach (FieldInfo fi in AllMasterFields)
                {
                    number += fi.FieldName == "Number" ? fi.DataValue.ToString() + "-" + suppliercode : "";

                    foreach (FieldInfo supplierfi in supplierfields)
                    {
                        if (fi.DisplayName == supplierfi.DisplayName)
                        {
                            if (supplierfi.FieldName == "NVARCHAR1")
                            {
                                fi.DataValue = number;
                                strField += supplierfi.FieldName + ",";
                                strValue += "'" + number + "',";
                            }

                            else
                            {
                                strField += supplierfi.FieldName + ",";
                                strValue += "'" + fi.DataValue.ToString() + "',";
                            }
                        }
                    }
                }

                strField += "DATETIME2,";
                strValue += "GetDate(),";

                string vendorname = DbHelperSQL.GetSingle<string>("select SupplierName from SYS_Supplier where SupplyCode=@SupplyCode", new SqlParameter("@SupplyCode",suppliercode));
                vendorname = suppliercode + "[" + vendorname + "]";

                strField += "NVARCHAR7,";
                strValue += "'" + vendorname + "',";

                strField = strField.TrimEnd(',');
                strValue = strValue.TrimEnd(',');
                bool existsRFQNumber = DbHelperSQL.Exists("select count(*) from SGP_SubData where NVARCHAR1=@Number and EntityName='VVIDETAIL' ", new SqlParameter("@Number", number));
                if (existsRFQNumber == false)
                {
                    try
                    {
                        int maxdataindex = -1;
                        maxdataindex = DbHelperSQL.GetSingle<int>("select Max(DataIndex) from SGP_SubData where EntityID=" + ID.ToString() + " and EntityName='VVIDETAIL'");
                        maxdataindex++;
                        string strSql = "insert into SGP_SubData(DataIndex,EntityID,EntityName," + strField + ") values(" + maxdataindex.ToString() + "," + ID.ToString() + ",'VVIDETAIL'," + strValue + ")";
                        DbHelperSQL.ExecuteSql(strSql);
                        string vendormail = "";
                        try
                        {
                            WF.WFUser user = new WF.WFUser(suppliercode);
                            if (user != null)
                            {
                                vendormail = user.Email;
                            }
                            else
                            {
                                vendormail = "*****@*****.**";
                            }
                        }
                        catch
                        {
                            vendormail = "*****@*****.**";
                        }

                       // wf.Run();
                        sysmgs.isPass = true;
                        sysmgs.MessageType = "Success";
                        sysmgs.Messages.Add("OK", number);
                        BI.SGP.BLL.WF.WFTemplate wftemplate = new WF.WFTemplate("SUPPLIERWF", ID, number);
                        BI.SGP.BLL.WF.WFActivity wfactivity = wftemplate.FirstActivity;
                        BI.SGP.BLL.WF.Action.SendMailAction sendmail = new WF.Action.SendMailAction();
                        sendmail.DoActionForVVI(wfactivity, vendorname, vendormail);

                        string strsql1 = "update SGP_RFQForVVI set ActivityID=102 where (ActivityID in(101) or ActivityID is null) and RFQID=@RFQID";

                        string strsql2 = "insert into SYS_WFProcessLog select @RFQID,3,@FromActivityID,@ToActivityID,0,GetDate(),@UserID,@Comment";

                        SqlParameter[] sp1 = new SqlParameter[] { new SqlParameter("@RFQID", ID) };

                        SqlParameter[] sp2 = new SqlParameter[] { new SqlParameter("@RFQID",ID),
                                                                  new SqlParameter("@FromActivityID",101),
                                                                  new SqlParameter("@ToActivityID",102),
                                                                  new SqlParameter("@UserID", BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid),
                                                                  new SqlParameter("@Comment", "Assign RFQ")};

                        DbHelperSQL.ExecuteSql(strsql1, sp1.ToArray());
                        DbHelperSQL.ExecuteSql(strsql2, sp2.ToArray());

                        AddHistory();
                    }
                    catch (Exception ex)
                    {
                        sysmgs.isPass = false;
                        sysmgs.MessageType = "Error";
                        sysmgs.Messages.Add("Error",ex.Message);
                    }
                }
                else
                {
                    sysmgs.isPass = false;
                    sysmgs.MessageType = "already exists";
                    sysmgs.Messages.Add("already exists", number);
                }
            }
            catch (Exception ex)
            {
                sysmgs.isPass = false;
                sysmgs.MessageType = "Error";
                sysmgs.Messages.Add("Error", ex.Message);
            }
            return sysmgs;
        }
Esempio n. 6
0
        public static void PostRFQToVVI(int RFQID)
        {
            List<RFQDetail> rfqdetails = RFQManager.GetDetail(RFQID);
            if (rfqdetails.Count > 0)
            {
                RFQDetail rfqdetail = rfqdetails[0];
                RFQDetail rfqdetailvvimultek = rfqdetail;
                if (rfqdetail.RFQID > 0)
                {

                    WF.WFTemplate wf = new WF.WFTemplate("DefaultWF", rfqdetail == null ? 0 : rfqdetail.RFQID);
                    if ((rfqdetail.RequestVVI.IndexOf("VVI")>=0) && rfqdetail.RFQID > 0 && wf.CurrentActivity.ID == 2)
                    {
                            if(rfqdetail.RequestVVI.IndexOf("Multek")>=0)
                            {
                               string newInternalNumber="";
                               rfqdetailvvimultek = RFQManager.GetDetailById(CreateNewRFQIDBuildingChangeForVVIMultek(rfqdetail.RFQID, rfqdetail, "HK", "01", SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid, out newInternalNumber));
                            }
                            if (IsPost(rfqdetailvvimultek.RFQID.ToString()) <= 0)
                            {
                                string sql = @"Insert into [SGP_RFQForVVI](
                                            RFQID,Number,[OEM],GAMBDM,CustomerPartNumber,Revision,MarketSegment,[Application],
                                            MassProductionEAU,MassProductionDate,CostDateIn,CostDateOut,
                                            StatusID,ActivityID,TemplateID,CreationTime,LastUpdate,EmployeeID)
                                            Select RFQID,Number,[OEM],GAMBDM,CustomerPartNumber,Revision,MarketSegment,[Application],
                                            VolumePerMonth,MassProductionDate,QuoteDateIn,QuoteDateOut,
                                            1,101,3,GETDATE(),GETDATE(),EmployeeID from V_SGP where RFQID=" + rfqdetailvvimultek.RFQID + "";
                                DbHelperSQL.ExecuteSql(sql);

                            }

                            if (IsAttachment(rfqdetailvvimultek.RFQID.ToString()) <= 0)
                            {
                                string sqlattachment = string.Format(@" INSERT INTO SGP_FilesForVVI([RelationKey],[FileName],[SourceName],[Folder],[FileSize],[Category],[CategoryDesc],[CreateTime],[Creator],[Status])
                                          SELECT RelationKey,[FileName],[SourceName],[Folder],[FileSize],[Category],[CategoryDesc],[CreateTime],[Creator],[Status] FROM [SGP_Files] WHERE RelationKey='{0}'", rfqdetailvvimultek.RFQID.ToString());
                                DbHelperSQL.ExecuteSql(sqlattachment);

                                string sqlqueryattachment = string.Format(@"SELECT RelationKey,[FileName],[SourceName],[Folder],[FileSize],[Category],[CategoryDesc],[CreateTime],[Creator],[Status] FROM [SGP_Files] WHERE RelationKey='{0}'", rfqdetailvvimultek.RFQID.ToString());

                                DataTable dt = DbHelperSQL.Query(sqlqueryattachment).Tables[0];
                                string targetdir = System.Configuration.ConfigurationManager.AppSettings["FilesFolderForVVI"].TrimEnd('\\') + "\\" + rfqdetailvvimultek.RFQID.ToString();

                                DirectoryInfo di = new DirectoryInfo(targetdir);

                                foreach (DataRow dr in dt.Rows)
                                {
                                    string sourcefilename = System.Configuration.ConfigurationManager.AppSettings["FilesFolder"].TrimEnd('\\') + "\\" + rfqdetailvvimultek.RFQID.ToString() + "\\" + dr["FileName"].ToString();
                                    string targetfullname = targetdir + "\\" + dr["FileName"].ToString();
                                    if (di.Exists)
                                    {
                                        if (File.Exists(sourcefilename))
                                        {
                                            File.Copy(sourcefilename, targetfullname, true);
                                        }
                                    }
                                    else
                                    {
                                        di.Create();
                                        if (File.Exists(sourcefilename))
                                        {
                                            File.Copy(sourcefilename, targetfullname, true);
                                        }
                                    }
                                }
                            }

                        //DirectoryInfo di = new DirectoryInfo(@"D:\TMP1\ZY");
                        //if (di.Exists)
                        //{
                        //    File.Copy(@"D:\TMP\ZY\zy.txt", @"D:\TMP1\ZY\zy.txt", true);
                        //}
                        //else
                        //{
                        //    di.Create();
                        //    File.Copy(@"D:\TMP\ZY\zy.txt", @"D:\TMP1\ZY\zy.txt", true);
                        //}
                        //string strsql1 = "update SGP_RFQ set ActivityID=7,StatusID=9 where id=@RFQID";

                        //string strsql2 = "insert into SYS_WFProcessLog select @RFQID,1,@FromActivityID,@ToActivityID,0,GetDate(),@UserID,@Comment";

                        //SqlParameter[] sp1 = new SqlParameter[] { new SqlParameter("@RFQID", rfqdetail.RFQID) };

                        //SqlParameter[] sp2 = new SqlParameter[] { new SqlParameter("@RFQID",rfqdetail.RFQID),
                        //                                          new SqlParameter("@FromActivityID",wf.CurrentActivity.ID),
                        //                                          new SqlParameter("@ToActivityID",7),
                        //                                          new SqlParameter("@UserID", BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid),
                        //                                          new SqlParameter("@Comment", "Force Close RFQ")};

                        //DbHelperSQL.ExecuteSql(strsql1, sp1.ToArray());
                        //DbHelperSQL.ExecuteSql(strsql2, sp2.ToArray());
                    }

                }
            }
        }
Esempio n. 7
0
        public static void ForceCloseRFQ(int RFQID)
        {
            List<RFQDetail> rfqdetails = RFQManager.GetDetail(RFQID);
            if (rfqdetails.Count > 0)
            {
                RFQDetail rfqdetail = rfqdetails[0];
                if (rfqdetail.RFQID > 0)
                {

                    WF.WFTemplate wf = new WF.WFTemplate("DefaultWF", rfqdetail == null ? 0 : rfqdetail.RFQID);
                    if (rfqdetail.HitRateStatus != "Pending" && string.IsNullOrEmpty(rfqdetail.HitRateStatus) == false && wf.CurrentActivity.ID != 7 && rfqdetail.RFQID > 0)
                    {

                        string strsql1 = "update SGP_RFQ set ActivityID=7,StatusID=9 where id=@RFQID";

                        string strsql2 = "insert into SYS_WFProcessLog select @RFQID,1,@FromActivityID,@ToActivityID,0,GetDate(),@UserID,@Comment";

                        SqlParameter[] sp1 = new SqlParameter[] { new SqlParameter("@RFQID", rfqdetail.RFQID) };

                        SqlParameter[] sp2 = new SqlParameter[] { new SqlParameter("@RFQID",rfqdetail.RFQID),
                                                                  new SqlParameter("@FromActivityID",wf.CurrentActivity.ID),
                                                                  new SqlParameter("@ToActivityID",7),
                                                                  new SqlParameter("@UserID", BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid),
                                                                  new SqlParameter("@Comment", "Force Close RFQ")};

                        DbHelperSQL.ExecuteSql(strsql1, sp1.ToArray());
                        DbHelperSQL.ExecuteSql(strsql2, sp2.ToArray());
                    }

                }
            }
        }