Ejemplo 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);
 }
Ejemplo n.º 2
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");
        }