Exemplo n.º 1
0
 public ActionResult BatchSubmitVendorRFQ()
 {
     string keyValues = Request.QueryString["NUMBER"];
     SystemMessages sysMsg = WFHelper.CreateMessages();
     string errorMsg = string.Empty;
     if (!string.IsNullOrEmpty(keyValues))
     {
         string[] numbers = keyValues.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
         SupplierRFQDetail sr = new SupplierRFQDetail();
         foreach (string number in numbers)
         {
             using (TScope ts = new TScope())
             {
                 SystemMessages msg = WFHelper.CreateMessages();
                 int id = sr.GetSupplierRFQId(number);
                 WFTemplate wfTemplate = new WFTemplate("SUPPLIERWF", id, number);
                 wfTemplate.FirstActivity.CheckData(msg);
                 if (!msg.isPass)
                 {
                     ts.Rollback();
                     sysMsg.isPass = false;
                     sysMsg.Messages.Add("Submit Fail", msg.MessageString);
                 }
                 else
                 {
                     sr.UpdateSupplierRfqStatus(id, number);
                     SkipRFQWFToNextForVVI(id, msg);
                     wfTemplate.LastActivity.DoAction();
                     sysMsg.Messages.Add("Submit Success", string.Format("{0} Submit Success", number));
                 }
             }
         }
     }
     return Json(sysMsg);
 }
Exemplo n.º 2
0
        //public ActionResult SupplierPricingDetail(SGP.BLL.Models.VVIRFQManager vvrfq)
        //{
        //    int id = 0;
        //    if (Request.QueryString["ID"] != null)
        //    {
        //        int.TryParse(Request.QueryString["ID"], out id);
        //        vvrfq = VVIRFQManager.GetDetail(id)[0];
        //    }
        //    return View(vvrfq);
        //}
        public ActionResult SupplierPricingDetail(string ID, string number)
        {
            int dataId = ParseHelper.Parse<int>(ID);

            WFTemplate template = new WFTemplate(4, dataId, number);
            List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_SGPFORSUPPLIER);

            if (dataId > 0)
            {
                SupplierRFQDetail vd = new SupplierRFQDetail(lfc, dataId, number);
                //vd.FillCategoryData(lfc, dataId, number);
                //vd.InitAutoCalculateColumns(lfc);
            }

            ViewBag.WFTemplate = template;
            ViewBag.Categories = lfc;
            ViewBag.DataId = dataId;
            ViewBag.Number = number;
            ViewBag.wfStatus = template.Status == WorkflowStatus.Finished ? "Finished" : "";
            return View("SupplierPricingDetail");
        }
Exemplo n.º 3
0
        public ActionResult GetComputedValue(string postData)
        {
            System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
            Dictionary<string, object> jsonData = jss.Deserialize<Dictionary<string, object>>(postData) as Dictionary<string, object>;

            double UnitSizeWidth = ParseHelper.Parse<double>(jsonData["UnitSizeWidth"]);
            double UnitSizeLength = ParseHelper.Parse<double>(jsonData["UnitSizeLength"]);
            double UnitArea = ParseHelper.Parse<double>(jsonData["UnitArea"]);
            double ArrayPerWorkingPanel = ParseHelper.Parse<double>(jsonData["ArrayPerWorkingPanel"]);
            double UnitPerArray = ParseHelper.Parse<double>(jsonData["UnitPerArray"]);
            double ArraySizeWidth = ParseHelper.Parse<double>(jsonData["ArraySizeWidth"]);
            double ArraySizeLength = ParseHelper.Parse<double>(jsonData["ArraySizeLength"]);
            double PanelSizeWidth = ParseHelper.Parse<double>(jsonData["PanelSizeWidth"]);
            double PanelSizeLength = ParseHelper.Parse<double>(jsonData["PanelSizeLength"]);
            double VariableCost = ParseHelper.Parse<double>(jsonData["VariableCost"]);

            SupplierRFQDetail detail = new SupplierRFQDetail();
            detail.UnitSizeWidth = UnitSizeWidth;
            detail.UnitSizeLength = UnitSizeLength;
            detail.UnitArea = UnitArea;
            detail.ArrayPerWorkingPanel = ArrayPerWorkingPanel;
            detail.UnitPerArray = UnitPerArray;
            detail.ArraySizeWidth = ArraySizeWidth;
            detail.ArraySizeLength = ArraySizeLength;
            detail.PanelSizeWidth = PanelSizeWidth;
            detail.PanelSizeLength = PanelSizeLength;
            detail.VariableCost = VariableCost;

            string panelUtilization = detail.PanelUtilization;
            string sqInchPriceUSD = detail.SqInchPriceUSD;

            var jsonObject = new
            {
                PanelUtilization = panelUtilization,
                SqInchPriceUSD = sqInchPriceUSD
            };

            return Json(jsonObject, JsonRequestBehavior.AllowGet);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Save data for supplier RFQ
        /// </summary>
        /// <param name="postData"></param>
        /// <param name="sysMsg"></param>
        /// <returns></returns>
        /// Lance Chen 20150126
        private int SupplierRfqSave(string postData, SystemMessages sysMsg, out bool isOutOfCapability)
        {
            isOutOfCapability = false;
            int id = 0;
            if (!string.IsNullOrEmpty(postData))
            {
                System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
                Dictionary<string, object> jsonData = jss.Deserialize<Dictionary<string, object>>(postData) as Dictionary<string, object>;

                string dataId = Convert.ToString(jsonData["dataId"]);
                string number = Convert.ToString(jsonData["number"]);
                string operation = Convert.ToString(jsonData["operation"]);
                Int32.TryParse(dataId, out id);
                Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;

                List<FieldCategory> lfc = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_SGPFORSUPPLIER);

                foreach (FieldCategory fc in lfc)
                {
                    if (data.ContainsKey(fc.ID))
                    {
                        fc.CheckDataType(data[fc.ID] as Dictionary<string, object>, sysMsg);
                    }
                }

                if (sysMsg.isPass)
                {
                    using (TScope ts = new TScope())
                    {
                        try
                        {
                            SupplierRFQDetail dm = new SupplierRFQDetail(lfc, data);

                            if (id > 0)
                            {
                                dm.UpdateSubDataForSupplierRfq(id, number, out isOutOfCapability);
                                if (operation == "Submit")
                                {
                                    dm.UpdateSupplierRfqStatus(id, number);
                                    dm.AddSupplierRFQHistory(id, number, "Submit", sysMsg);
                                }
                                else
                                {
                                    dm.AddSupplierRFQHistory(id, number, "Save", sysMsg);
                                }
                            }
                            else
                            {
                                sysMsg.isPass = false;
                                sysMsg.Messages.Add("Error", "Please select a RFQ ");
                            }
                        }
                        catch (Exception ex)
                        {
                            ts.Rollback();
                            sysMsg.isPass = false;
                            sysMsg.Messages.Add("Error", ex.Message);
                        }
                    }
                }
            }
            return id;
        }
Exemplo n.º 5
0
        private int SUPPLIERRFQSave(string postData, SystemMessages sysMsg)
        {
            int id = 0;
            if (!String.IsNullOrWhiteSpace(postData))
            {
                System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
                Dictionary<string, object> jsonData = jss.Deserialize<Dictionary<string, object>>(postData) as Dictionary<string, object>;

                string dataId = Convert.ToString(jsonData["dataId"]);
                string operation = Convert.ToString(jsonData["operation"]);
                Int32.TryParse(dataId, out id);
                Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;

                List<FieldCategory> lfc = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_VVI);

                foreach (FieldCategory fc in lfc)
                {
                    if (data.ContainsKey(fc.ID))
                    {
                        fc.CheckDataType(data[fc.ID] as Dictionary<string, object>, sysMsg);
                    }
                }

                if (sysMsg.isPass)
                {
                    using (TScope ts = new TScope())
                    {
                        try
                        {
                            SupplierRFQDetail dm = new SupplierRFQDetail(lfc, data);
                            if (operation == SupplierRFQDetail.OPERATION_REQUOTE)
                            {
                                id = dm.ReQuote();
                            }
                            else if (operation == SupplierRFQDetail.OPERATION_CLONE)
                            {
                                id = dm.Clone();
                            }
                            else
                            {
                                if (id > 0)
                                {
                                    dm.Update(id);
                                }
                                else
                                {
                                    id = dm.Add();
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            ts.Rollback();
                            sysMsg.isPass = false;
                            sysMsg.Messages.Add("Error", ex.Message);
                        }
                    }
                }
            }

            return id;
        }
Exemplo n.º 6
0
        public ActionResult SupplierRFQLoadExcel()
        {
            DataTable dt = new DataTable();

            string message = string.Empty;
            bool flag = SaveAndReadFile(out dt, out message);
            DataSet ds = dt.DataSet;
            List<string> numbers = new List<string>();

            if (flag == true && dt != null)
            {
                DataTable mainTable = ds.Tables["Primary"];

                FieldInfoCollecton fields = FieldCategory.GetAllFields(FieldCategory.Category_TYPE_SGPFORSUPPLIER);
                ModelHandler<object>.ColumnNameToFieldName(dt, fields);

                if (!dt.Columns.Contains("Message")) dt.Columns.Add("Message", typeof(string));

                List<FieldCategory> categories = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_SGPFORSUPPLIER);

                foreach (DataRow dr in mainTable.Rows)
                {
                    try
                    {
                        SupplierRFQDetail sr = new SupplierRFQDetail();
                        SystemMessages sysMsg = WFHelper.CreateMessages();
                        int i = sr.UpdateSupplierRFQByExcel(dr, categories);
                        if(i > 0)
                        {
                            string number = dr["NVARCHAR1"].ToString();
                            numbers.Add(number);
                            int id = sr.GetSupplierRFQId(number);
                            sr.AddSupplierRFQHistory(id, number, "Upload", sysMsg);
                            if (!sysMsg.isPass)
                            {
                                throw new Exception(sysMsg.Messages[0].ToString());
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        dr["Message"] = ex.Message;
                    }
                }

                dt.Columns["Message"].SetOrdinal(0);
                ModelHandler<object>.ColumnNameToDisplayName(dt, fields);

                DataView dv = dt.DefaultView;
                dv.Sort = "Message Desc";
                ViewData["ExcelData"] = dv.ToTable();
                successdt = dt;
                message = string.Empty;
            }

            ViewData["MSG"] = message;
            ViewData["NUMBER"] = string.Join(",", numbers.ToArray());
            return View("~/Views/VVI/SupplierRFQImportExcel.cshtml");
        }