Exemplo n.º 1
0
        public static int RigidPCBORFPC(DataRow dr)
        {
            ///0 Fail,1 PCB, 2 FPC
            ///
            SystemMessages sysmgs = new SystemMessages();
            int result=0;
            DataTable dt = dr.Table;
            DataColumnCollection cols = dt.Columns;
            string[] keycols = { "Number", "Internal RFQ Number", "External RFQ Number", "ExtNumber" };
            string[] typecols = { "TypeOfQuote", "Type Of Product" };
            string[] defineFPC={"FPC","FPCA"};
            ArrayList keylist = new ArrayList();
            ArrayList typelist = new ArrayList();

            foreach (DataColumn col in cols)
            {
                if (keycols.Contains(col.ColumnName))
                {
                    if (string.IsNullOrEmpty(dr[col.ColumnName].ToString()) == false)
                    {
                        keylist.Add(dr[col.ColumnName].ToString());
                    }
                }
                if (typecols.Contains(col.ColumnName))
                {
                    if (string.IsNullOrEmpty(dr[col.ColumnName].ToString()) == false)
                    {
                        typelist.Add(dr[col.ColumnName].ToString());
                    }
                }
            }
            RFQDetail rfqdeatil = new RFQDetail();

            if (typelist.Count > 0)
            {
                foreach (string t in typelist)
                {
                    if (defineFPC.Contains(t))
                    {
                        result = 2;
                    }
                    else
                    {
                        result = 1;
                    }

                }

            }
            else if (keylist.Count > 0)
            {
                foreach (string k in keylist)
                {
                    rfqdeatil = RFQManager.GetLastDetailByExtNumber(k.Substring(0, 16));
                    if (rfqdeatil != null)
                    {
                        if (defineFPC.Contains(rfqdeatil.TypeOfQuote))
                        {
                            result = 2;
                        }
                        else
                        {
                            result = 1;
                        }
                    }
                    else
                    {
                        result = 0;
                    }
                }

            }
            else
            {
                result=0;
            }

            return result;
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据Number查找RFQ
        /// </summary>
        /// <param name="intNumber"></param>
        /// <returns></returns>
        public static RFQDetail GetDetailByInternalNumber(string intNumber)
        {
            string strSql = "SELECT * FROM V_SGP where Number = @RFQnumber";
            DataTable dt = DbHelperSQL.Query(strSql, new SqlParameter("@RFQnumber", intNumber)).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                RFQDetail detail = new RFQDetail();
                FillRFQData(detail, dt.Rows[0]);
                return detail;
            }
            return null;
        }
Exemplo n.º 3
0
        public static RFQDetail GetLastDetailByExtNumber(string extNumber)
        {
            string strSql = "SELECT TOP 1 * FROM V_SGP where ExtNumber = @EXTnumber ORDER BY Number DESC";
            DataTable dt = DbHelperSQL.Query(strSql, new SqlParameter("@EXTnumber", extNumber)).Tables[0];

            if (dt != null && dt.Rows.Count > 0)
            {
                RFQDetail detail = new RFQDetail();
                FillRFQData(detail, dt.Rows[0]);
                return detail;
            }
            return null;
        }
Exemplo n.º 4
0
 private static void FillRFQData(RFQDetail Detail, DataRow dr)
 {
     Type tp = typeof(RFQDetail);
     //FieldInfoCollecton fields = FieldCategory.GetAllFields();
     for (int i = 0; i < dr.Table.Columns.Count; i++)
     {
         string propertyName = dr.Table.Columns[i].ColumnName;
         PropertyInfo propertyinfo = tp.GetProperty(propertyName);
         //if (propertyinfo == null) {
         //    BI.SGP.BLL.DataModels.FieldInfo fi=fields.Find(t=>t.FieldName)
         //}
         if (propertyinfo != null && dr[i] != DBNull.Value)
         {
             propertyinfo.SetValue(Detail, dr[i], null);
         }
     }
     Detail.ID = Detail.RFQID;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Get RFQDetail modal class 
        /// </summary>
        /// <param name="RFQID"></param>
        /// <returns></returns>
        public static List<RFQDetail> GetDetail(int RFQID)
        {
            string strSql = "SELECT * FROM V_SGP where rfqid = @RFQID";
            DataTable dt = DbHelperSQL.Query(strSql, new SqlParameter("@RFQID", RFQID)).Tables[0];

            List<RFQDetail> DetailData = new List<RFQDetail>();

            if (dt.Rows.Count == 0)
            {
                return DetailData;
            }

            foreach (DataRow dr in dt.Rows)
            {
                RFQDetail Detail = new RFQDetail();

                for (int i = 0; i < dr.Table.Columns.Count; i++)
                {
                    FillRFQData(Detail, dr);
                }
                DetailData.Add(Detail);

            }

            return DetailData;
        }
Exemplo n.º 6
0
        /// <summary>
        /// 在BUILDING改变的时候使用这个方法,创建新数据,或者根据情况返回已存在的数据的ID
        /// </summary>
        /// <param name="oldRFQId"></param>
        /// <param name="rfqDetail"></param>
        /// <param name="newBuilding"></param>
        /// <param name="newRev"></param>
        /// <param name="uid"></param>
        /// <returns></returns>
        private static int CreateNewRFQID4BuildingChange(int oldRFQId, RFQDetail rfqDetail, string newBuilding, string newRev, string uid, out string newInternalNumber)
        {
            newInternalNumber = rfqDetail.Number;
            newRev = newRev.PadLeft(2, '0');
            string oldExtNumber = rfqDetail.ExtNumber;

            //如果BUILDING为空
            if (string.IsNullOrEmpty(newBuilding) && string.IsNullOrEmpty(rfqDetail.Building)) return oldRFQId;

            //如果新BUILDING为空,旧BUILDING不为空
            if (string.IsNullOrEmpty(newBuilding))
            {
                //throw new Exception
            }

            //如果BUILDING没有改变
            if (newBuilding == rfqDetail.Building)
            {
                //如果版本为空或者版本没有改变,则返回
                if (string.IsNullOrEmpty(newRev) || newRev == rfqDetail.InternalRevisionNumber)
                {
                    return oldRFQId;
                }
            }

            //如果没有提供REV则默认为01
            if (string.IsNullOrEmpty(newRev)) newRev = "01";

            newRev = newRev.PadLeft(2, '0');

            //合成新的内部号码,格式:GPMCN0023066-000-05B4
            newInternalNumber = string.Format("{0}-{1}{2}", oldExtNumber, newRev, newBuilding);

            //检查该内部号码是否已经存在
            string sql = string.Format("SELECT ID FROM SGP_RFQ WHERE Number='{0}'", newInternalNumber);
            int existsId = DbHelperSQL.GetSingle<int>(sql);

            if (existsId == oldRFQId) return oldRFQId;

            //如果已经存在记录,并且不是当前记录的话
            if (existsId != 0 && existsId != oldRFQId)
            {
                return existsId;
                //throw new Exception(string.Format("The RFQ[{0}] for Building[{1}], rev[{2}] alrady exists in system."
                //    , newInternalNumber, newBuilding, newRev));
            }

            //创建新的RFQ数据
            int rfqId = CreateNewRFQ4AllTables(newInternalNumber, oldExtNumber, newBuilding, newRev, uid);

            //克隆数据从旧的RFQ
            CloneData(oldRFQId, rfqId);
            //将新的RFQ状态同步过去
            CloneWorkflowStatus(oldRFQId, rfqId);
            //克隆附件
            CloneAttachments(oldRFQId, rfqId);

            return rfqId;
        }
Exemplo n.º 7
0
        private static int CreateNewRFQID4ReQuote(int oldRFQId, RFQDetail rfqDetail, string uid)
        {
            string internalNumber = rfqDetail.Number;
            string extNumber = rfqDetail.ExtNumber;
            string newSeq = "";
            int p = 0;

            string prefix = extNumber;
            p = extNumber.IndexOf('-');
            if (p > 0)
            {
                string[] ary = extNumber.Split('-');
                prefix = ary[0];
            }

            string sql = string.Format("SELECT ExtNumber from SGP_RFQ WHERE ExtNumber LIKE '{0}%' ORDER BY ExtNumber DESC", prefix);
            string lastExtNumber = DbHelperSQL.GetSingle<string>(sql);
            p = lastExtNumber.IndexOf('-');
            if (p > 0)
            {
                string[] ary = lastExtNumber.Split('-');
                string lastSeq = ary[1];
                int intLastSeq = 0;
                Int32.TryParse(lastSeq, out intLastSeq);
                intLastSeq++;
                newSeq = intLastSeq.ToString().PadLeft(3, '0');
            }
            if (string.IsNullOrEmpty(newSeq)) newSeq = "001";

            string newExtNumber = string.Format("{0}-{1}", prefix, newSeq);
            string newIntNumber = string.Format("{0}", newExtNumber);
            //创建新的RFQ数据
            int rfqId = CreateNewRFQ4AllTables(newIntNumber, newExtNumber, string.Empty, "01", uid);

            //将新的数据复制过去
            CloneData(oldRFQId, rfqId);

            return rfqId;
        }
Exemplo n.º 8
0
        private void SaveAs(ref RFQDetail rfdetail, ref SystemMessages sysmgs)
        {
            //check data检查数据,返回状态到sysmgs
            RFQManager.CheckData(Request, ref sysmgs);

            //检查数据通过则执行保存到数据库
            if (sysmgs.isPass)
            {
                NameValueCollection Result = BI.SGP.BLL.Models.RFQManager.SaveAs(Request);

                //if (Result["RFQID"] != null && Result["Mgs"] != null)
                //{

                //    sysmgs.isPass = false;
                //    sysmgs.MessageType = "Update Error";
                //    sysmgs.Messages.Add("Update Error", Result["Mgs"]);

                //}
                string ID = Result["RFQID"];
                int rfqId = 0; Int32.TryParse(ID, out rfqId);

                //有MSG返回,表示保存失败
                if (string.IsNullOrEmpty(Result["Mgs"]) == false)
                {
                    sysmgs.isPass = false;
                    sysmgs.MessageType = "Save Error";
                    sysmgs.Messages.Add("Save Error", Result["Mgs"]);

                }
                else
                {
                    sysmgs.isPass = true;
                    sysmgs.MessageType = "Save Success";
                    //sysmgs.Messages.Add("Save Success", Result["Mgs"]);
                }

                if (rfqId > 0)
                {
                    if (BI.SGP.BLL.Models.RFQManager.GetDetail(rfqId) != null)
                    {
                        rfdetail = BI.SGP.BLL.Models.RFQManager.GetDetail(rfqId)[0];
                    }
                }

            }
            else // 检查数据不通过
            {
                sysmgs.MessageType = "Error";
            }

            //sysmgs.Messages.Add("RFQ:", "format error");
        }
Exemplo n.º 9
0
        public ActionResult SaveSubmitData()
        {
            RFQDetail rfdetail = new RFQDetail();
            SystemMessages sysmgs = new SystemMessages();

            Save(ref rfdetail, ref sysmgs);
            WFTemplate wfTemplate = new WFTemplate("DefaultWF", rfdetail.RFQID);

            if (sysmgs.isPass)
            {
                try
                {

                    if (RFQManager.IsPendingStatus(rfdetail.RFQID, wfTemplate.NextActivity.ID) == false)
                    {
                        sysmgs.isPass = false;
                        sysmgs.Messages.Add("System Exception", "the HitRate Status is Pending, do not allow go to the Closure Status");
                    }
                    else
                    {
                        sysmgs.Merge(wfTemplate.Run());
                    }
                    RFQManager.PostRFQToVVI(rfdetail.RFQID);
                }
                catch (Exception ex)
                {
                    sysmgs.isPass = false;
                    sysmgs.Messages.Add("System Exception", ex.Message);
                }
            }
            string[] WFIDS = { "5", "6", "7" };
            string PDFDIV = "";
            if (WFIDS.Contains(wfTemplate.CurrentActivity.ID.ToString()))
            {
                PDFDIV = @"<button id=""btnDownlPDF"" class=""btn btn-purple""   onclick=""return downloadpdf();"" >
                                                                 Download PDF
                                                                <i class=""icon-file small-30""></i>
                                                                 </button>";
            }

            var returnData = new
            {
                HTML = SGP.BLL.UIManager.UIManager.GenrateModelforRFQDetail(rfdetail, wfTemplate.CurrentActivity.ID.ToString()),
                RFQNumber = rfdetail.Number,
                RFQID = rfdetail.RFQID,
                SysMsg = sysmgs,
                PDF = PDFDIV
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 10
0
        public ActionResult SaveRequoteData()
        {
            RFQDetail rfdetail = new RFQDetail();
            SystemMessages sysmgs = new SystemMessages();

            ReQuote(ref rfdetail, ref sysmgs);

            SGP.BLL.WF.WFTemplate wf = new WFTemplate(1, rfdetail.RFQID);
            // string aa = Request.Form["Number"];
            var returnData = new
            {
                HTML = SGP.BLL.UIManager.UIManager.GenrateModelforRFQDetail(rfdetail, wf.CurrentActivity.ID.ToString()),
                RFQNumber = rfdetail.Number,
                RFQID = rfdetail.RFQID,
                SysMsg = sysmgs
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 11
0
        /// <summary>
        /// 通过AJAX实时计算各个值
        /// </summary>
        /// <returns></returns>
        public ActionResult GetComputedValue()
        {
            string UnitPrice1 = Request.QueryString["UnitPrice1"];
            string UnitPrice2 = Request.QueryString["UnitPrice2"];
            string UnitPrice3 = Request.QueryString["UnitPrice3"];
            string UnitPrice4 = Request.QueryString["UnitPrice4"];
            string UnitPrice5 = Request.QueryString["UnitPrice5"];
            string UnitPrice6 = Request.QueryString["UnitPrice6"];
            string UnitPrice7 = Request.QueryString["UnitPrice7"];
            string UnitPrice8 = Request.QueryString["UnitPrice8"];
            string UnitPrice9 = Request.QueryString["UnitPrice9"];
            string UnitPrice10 = Request.QueryString["UnitPrice10"];

            string FixedCost = Request.QueryString["FixedCost"];
            string MaterialCost = Request.QueryString["MaterialCost"];
            string VariableCost = Request.QueryString["VariableCost"];
            string UnitPerWorkingPanel = Request.QueryString["UnitPerWorkingPanel"];
            string ArraySizeWidth = Request.QueryString["ArraySizeWidth"];
            string ArraySizeLength = Request.QueryString["ArraySizeLength"];
            string PanelSizeWidth = Request.QueryString["PanelSizeWidth"];
            string PanelSizeLength = Request.QueryString["PanelSizeLength"];
            string TargetPrice = Request.QueryString["TargetPrice"];

            string ExchangRatePerUSD = Request.QueryString["ExchangRatePerUSD"];
            string ShipTermsAdder = Request.QueryString["ShipTermsAdder"];
            string MinSqInch1 = Request.QueryString["MinSqInch"];
            string LayerCount = Request.QueryString["LayerCount"];
            string UnitPerArray = Request.QueryString["UnitPerArray"];
            string UnitType = Request.QueryString["UnitType"];
            string TotalCost1 = Request.QueryString["TotalCost"];

            RFQDetail detail = new RFQDetail();
            double UnitPrice1Int = 0; double.TryParse(UnitPrice1, out UnitPrice1Int);
            double UnitPrice2Int = 0; double.TryParse(UnitPrice2, out UnitPrice2Int);
            double UnitPrice3Int = 0; double.TryParse(UnitPrice3, out UnitPrice3Int);
            double UnitPrice4Int = 0; double.TryParse(UnitPrice4, out UnitPrice4Int);
            double UnitPrice5Int = 0; double.TryParse(UnitPrice5, out UnitPrice5Int);
            double UnitPrice6Int = 0; double.TryParse(UnitPrice6, out UnitPrice6Int);
            double UnitPrice7Int = 0; double.TryParse(UnitPrice7, out UnitPrice7Int);
            double UnitPrice8Int = 0; double.TryParse(UnitPrice8, out UnitPrice8Int);
            double UnitPrice9Int = 0; double.TryParse(UnitPrice9, out UnitPrice9Int);
            double UnitPrice10Int = 0; double.TryParse(UnitPrice10, out UnitPrice10Int);
            double fixedCostInt = 0; double.TryParse(FixedCost, out fixedCostInt);
            double MaterialCostInt = 0; double.TryParse(MaterialCost, out MaterialCostInt);
            double VariableCostInt = 0; double.TryParse(VariableCost, out VariableCostInt);
            double UnitPerWorkingPanelInt = 0; double.TryParse(UnitPerWorkingPanel, out UnitPerWorkingPanelInt);
            double ArraySizeWidthInt = 0; double.TryParse(ArraySizeWidth, out ArraySizeWidthInt);
            double ArraySizeLengthInt = 0; double.TryParse(ArraySizeLength, out ArraySizeLengthInt);
            double PanelSizeWidthInt = 0; double.TryParse(PanelSizeWidth, out PanelSizeWidthInt);
            double PanelSizeLengthInt = 0; double.TryParse(PanelSizeLength, out PanelSizeLengthInt);
            double TargetPriceInt = 0; double.TryParse(TargetPrice, out TargetPriceInt);
            double ExchangRatePerUSDInt = 0; double.TryParse(ExchangRatePerUSD, out ExchangRatePerUSDInt);
            double ShipTermsAdderInt = 0; double.TryParse(ShipTermsAdder, out ShipTermsAdderInt);
            double MinSqInchInt = 0; double.TryParse(MinSqInch1.Replace('%', '0'), out MinSqInchInt);
            double LayerCountInt = 0; double.TryParse(LayerCount, out LayerCountInt);
            double UnitPerArrayInt = 0; double.TryParse(UnitPerArray, out UnitPerArrayInt);
            double TotalCostInt = 0; double.TryParse(TotalCost1, out TotalCostInt);

            detail.UnitPrice1 = UnitPrice1Int;
            detail.UnitPrice2 = UnitPrice2Int;
            detail.UnitPrice3 = UnitPrice3Int;
            detail.UnitPrice4 = UnitPrice4Int;
            detail.UnitPrice5 = UnitPrice5Int;
            detail.UnitPrice6 = UnitPrice6Int;
            detail.UnitPrice7 = UnitPrice7Int;
            detail.UnitPrice8 = UnitPrice8Int;
            detail.UnitPrice9 = UnitPrice9Int;
            detail.UnitPrice10 = UnitPrice10Int;

            detail.FixedCost = fixedCostInt;
            detail.MaterialCost = MaterialCostInt;
            detail.VariableCost = VariableCostInt;
            detail.UnitPerWorkingPanel = UnitPerWorkingPanelInt;
            detail.ArraySizeWidth = ArraySizeWidthInt;
            detail.ArraySizeLength = ArraySizeLengthInt;
            detail.PanelSizeWidth = PanelSizeWidthInt;
            detail.PanelSizeLength = PanelSizeLengthInt;
            detail.TargetPrice = TargetPriceInt;
            detail.ExchangRatePerUSD = ExchangRatePerUSDInt;
            detail.ShipTermsAdder = ShipTermsAdderInt;
            detail.MinSqInch = MinSqInchInt;
            detail.LayerCount = LayerCountInt;
            detail.UnitPerArray = UnitPerArrayInt;
            detail.UnitType = UnitType;
            detail.TotalCost = TotalCostInt;

            double TargetPrice1 = Math.Round(detail.TargetPrice, 2);
            double TargetASP = Math.Round(detail.TargetASP, 2);
            double MinASP = Math.Round(detail.MinASP, 2);
            double TargetASPL = Math.Round(detail.TargetASPL, 2);
            double MinASPL = Math.Round(detail.MinASPL, 2);
            double TargetSqIn = Math.Round(detail.TargetSqIn, 2);
            double MinSqInch = Math.Round(detail.MinSqInch, 2);
            double TargetCLsqin = Math.Round(detail.TargetCLsqin, 2);
            double MinCLsqin = Math.Round(detail.MinCLsqin, 2);
            double TargetVSActucal = Math.Round(detail.TargetVSActucal, 2);
            double TotalCost = Math.Round(detail.TotalCost, 4);
            double OP = Math.Round(detail.OP, 2);
            double MP = Math.Round(detail.MP, 2);
            double OP1 = Math.Round(detail.OP1, 2);
            double MP1 = Math.Round(detail.MP1, 2);
            double OP2 = Math.Round(detail.OP2, 2);
            double MP2 = Math.Round(detail.MP2, 2);
            double OP3 = Math.Round(detail.OP3, 2);
            double MP3 = Math.Round(detail.MP3, 2);
            double OP4 = Math.Round(detail.OP4, 2);
            double MP4 = Math.Round(detail.MP4, 2);
            double OP5 = Math.Round(detail.OP5, 2);
            double MP5 = Math.Round(detail.MP5, 2);
            double OP6 = Math.Round(detail.OP6, 2);
            double MP6 = Math.Round(detail.MP6, 2);
            double OP7 = Math.Round(detail.OP7, 2);
            double MP7 = Math.Round(detail.MP7, 2);
            double OP8 = Math.Round(detail.OP8, 2);
            double MP8 = Math.Round(detail.MP8, 2);
            double OP9 = Math.Round(detail.OP9, 2);
            double MP9 = Math.Round(detail.MP9, 2);
            double OP10 = Math.Round(detail.OP10, 2);
            double MP10 = Math.Round(detail.MP10, 2);
            string PanelUtilization = detail.PanelUtilization;

            var jsonObject = new
            {

                TargetASP = TargetASP,
                MinASP = MinASP,
                TargetASPL = TargetASPL,
                MinASPL = MinASPL,
                TargetSqIn = TargetSqIn,
                MinSqInch = MinSqInch,
                TargetCLsqin = TargetCLsqin,
                MinCLsqin = MinCLsqin,
                TargetVSActucal = TargetVSActucal,
                TotalCost = TotalCost,
                OP = OP,
                MP = MP,
                OP1 = OP1,
                MP1 = MP1,
                OP2 = OP2,
                MP2 = MP2,
                OP3 = OP3,
                MP3 = MP3,
                OP4 = OP4,
                MP4 = MP4,
                OP5 = OP5,
                MP5 = MP5,
                OP6 = OP6,
                MP6 = MP6,
                OP7 = OP7,
                MP7 = MP7,
                OP8 = OP8,
                MP8 = MP8,
                OP9 = OP9,
                MP9 = MP9,
                OP10 = OP10,
                MP10 = MP10,
                TargetPrice1 = TargetPrice1,
                PanelUtilization = PanelUtilization
            };

            return Json(jsonObject, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 12
0
        public ActionResult SubmitData()
        {
            RFQDetail rfdetail = new RFQDetail();
            SystemMessages sysmgs = new SystemMessages();
            try
            {
                WFTemplate wfTemplate = new WFTemplate("DefaultWF", rfdetail.RFQID);
                sysmgs.Merge(wfTemplate.Run());
            }
            catch (Exception ex)
            {
                sysmgs.isPass = false;
                sysmgs.Messages.Add("System Exception", ex.Message);
            }

            var returnData = new
            {
                RFQNumber = rfdetail.Number,
                RFQID = rfdetail.RFQID,
                SysMsg = sysmgs
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }