Exemple #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);
 }
Exemple #2
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;
        }