Beispiel #1
0
        /// <summary>
        /// Assign RFQ VVI to Supplier
        /// </summary>
        /// <returns></returns>
        /// 
        public ActionResult AssignSupplier()
        {
            SystemMessages sysMsg = new SystemMessages();
            int id = 0;
            string postData = Request["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>;
            Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;
            string dataId = Convert.ToString(jsonData["dataId"]);
            string operation = Convert.ToString(jsonData["operation"]);
            string suppliercode = Convert.ToString(jsonData["SupplierCode"]);
            List<FieldCategory> lfc = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_VVI);
            Int32.TryParse(dataId, out id);

            using (TScope ts = new TScope())
            {
                try
                {

                    VVIQuotationDetail dm = new VVIQuotationDetail(lfc, data);

                    if (id > 0)
                    {

                        dm.AssignVVIData(id, suppliercode, 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);
                }
            }
            string html = "";
            string wfStatus = "";

            VVIQuotationDetail b2Detail = new VVIQuotationDetail();
            // List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_VVI);
            b2Detail.FillCategoryData(lfc, id);
            WFTemplate wfTemplate = new WFTemplate("VVIWF", id);
            html = DetailUIHelper.GenrateCategories(lfc, wfTemplate);
            wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";

            var returnData = new
            {
                DataId = id,
                SysMsg = sysMsg,
                Html = html,
                wfStatus = wfStatus
            };

            return Json(returnData, JsonRequestBehavior.AllowGet);
        }
        public JsonResult BatchDelete()
        {
            SystemMessages sysMsg = new SystemMessages();
            string categoryName = Request["categoryName"];
            FieldCategory category = new FieldCategory(categoryName);

            using (TScope ts = new TScope())
            {
                try
                {
                    CostingMasterDetailData cmdd = new CostingMasterDetailData(category);
                    cmdd.BatchDelete();
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    sysMsg.isPass = false;
                    sysMsg.Messages.Add("Error", ex.Message);
                }
            }

            var jsonResult = new
            {
                success = sysMsg.isPass,
                errMessage = sysMsg.MessageString
            };
            return Json(jsonResult);
        }
Beispiel #3
0
        public ActionResult DelData()
        {
            string errMessage = "";
            int id = ParseHelper.Parse<int>(Request["id"]);

            using (TScope ts = new TScope())
            {
                try
                {
                    CostingInputDetail.Delete(id);
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    errMessage = ex.Message;
                }
            }

            var result = new
            {
                success = (errMessage == "" ? true : false),
                errMessage = errMessage
            };
            return Json(result);
        }
 public ActionResult CancelQuote(string keyValues)
 {
     SystemMessages sysMsg = new SystemMessages();
     if (!string.IsNullOrEmpty(keyValues))
     {
         using (TScope ts = new TScope())
         {
             try
             {
                 string[] ids = keyValues.Split(',');
                 if (ids != null && ids.Length > 0)
                 {
                     SCMPriceMasterDetail smd = new SCMPriceMasterDetail();
                     DateTime date = new DateTime();
                     foreach (string id in ids)
                     {
                         smd.DisableQuote(id, date);
                     }
                 }
             }
             catch (Exception ex)
             {
                 ts.Rollback();
                 sysMsg.isPass = false;
                 sysMsg.Messages.Add("Error", ex.Message);
             }
         }
     }
     var result = new
     {
         success = sysMsg.isPass,
         message = (sysMsg.isPass ? "" : sysMsg.Messages.ToString())
     };
     return Json(result);
 }
 /// <summary>
 /// 报价审批通过
 /// </summary>
 /// <param name="keyValues"></param>
 /// <returns></returns>
 public ActionResult ApproveQuote(string keyValues)
 {
     SystemMessages sysMsg = new SystemMessages();
     if (!string.IsNullOrEmpty(keyValues))
     {
         using (TScope ts = new TScope())
         {
             try
             {
                 SCMPriceMasterDetail smd = new SCMPriceMasterDetail();
                 string[] ids = keyValues.Split(',');
                 if (ids != null && ids.Length > 0)
                 {
                     DateTime approveDate = DateTime.Now;
                     foreach (string id in ids)
                     {
                         smd.ChangeQuoteStatus(id, SCMPriceMasterDetail.QuoteStatus_Approved, approveDate);
                         UpdateMainDataStatus(id);
                     }
                 }
             }
             catch (Exception ex)
             {
                 ts.Rollback();
                 sysMsg.isPass = false;
                 sysMsg.Messages.Add("Error", ex.Message);
             }
         }
     }
     var result = new
     {
         success = sysMsg.isPass,
         message = (sysMsg.isPass ? "" : sysMsg.Messages.ToString())
     };
     return Json(result);
 }
        public JsonResult DelData()
        {
            SystemMessages sysMsg = new SystemMessages();
            int id = 0;
            string dataId = Request["dataId"];
            string categoryName = Request["categoryName"];

            Int32.TryParse(dataId, out id);
            FieldCategory category = new FieldCategory(categoryName);

            using (TScope ts = new TScope())
            {
                try
                {
                    CostingPeriodDetail cpd = new CostingPeriodDetail(category);

                    if (id > 0)
                    {
                        cpd.Delete(id);
                    }
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    sysMsg.isPass = false;
                    sysMsg.Messages.Add("Error", ex.Message);
                }
            }

            var jsonResult = new
            {
                success = sysMsg.isPass,
                errMessage = sysMsg.MessageString
            };
            return Json(jsonResult);
        }
Beispiel #7
0
        private int VVISave(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
                        {

                            VVIQuotationDetail dm = new VVIQuotationDetail(lfc, data);

                            if (id > 0)
                            {

                                dm.UpdateForVVI(id);
                            }
                            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;
        }
Beispiel #8
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;
        }
 //Delete Visit List Actions Tracker Data
 public JsonResult DelActionsTrackerData(string ID)
 {
     string errMessage = "";
     int dataId = 0;
     if (int.TryParse(ID, out dataId))
     {
         using (TScope ts = new TScope())
         {
             try
             {
                 CustomerVisitActionsTrackerManager.DeleteVisitActionsTrackerData(ID);
             }
             catch (Exception ex)
             {
                 errMessage = ex.Message;
             }
         }
     }
     var result = new
     {
         success = (errMessage == "" ? true : false),
         errMessage = errMessage
     };
     return Json(result);
 }
Beispiel #10
0
        private int Save(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>;

                if (sysMsg.isPass)
                {
                    using (TScope ts = new TScope())
                    {
                        try
                        {
                            CustomerVisitManager dm = new CustomerVisitManager();
                            if (id > 0)
                            {
                                dm.Update(id, data);
                            }
                            else
                            {
                                id = dm.Add(data);
                            }
                        }
                        catch (Exception ex)
                        {
                            ts.Rollback();
                            sysMsg.isPass = false;
                            sysMsg.Messages.Add("Error", ex.Message);
                        }
                    }
                }
            }
            return id;
        }
Beispiel #11
0
        public ActionResult DeleteInvolvedPeople()
        {
            SystemMessages sysMsg = new SystemMessages();
            string id = Request["ID"];

            using (TScope ts = new TScope())
            {
                try
                {
                    CustomerVisitManager.DeletePeople(id);
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    sysMsg.isPass = false;
                    sysMsg.Messages.Add("Error", ex.Message);
                }
            }

            var jsonData = new
            {
                SysMsg = sysMsg
            };

            return Json(jsonData, JsonRequestBehavior.AllowGet);
        }
Beispiel #12
0
        public ActionResult GenerateCosting()
        {
            SystemMessages sysMsg = new SystemMessages();

            int id = 0;
            string postData = Request["postData"];
            id = Save(postData, sysMsg, true);

            if (sysMsg.isPass && id > 0)
            {
                CostHelper ch = new CostHelper();
                using (TScope ts = new TScope())
                {
                    try
                    {
                        ch.GenerateCosting(id);
                    }
                    catch (Exception ex)
                    {
                        ts.Rollback();
                        sysMsg.isPass = false;
                        sysMsg.Messages.Add("Error", ex.Message);
                    }
                }
            }

            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg
            };
            return Json(jsonResult);
        }
Beispiel #13
0
        public ActionResult WFSkip()
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();
            string html = "";
            string wfStatus = "";

            string postData = Request["postData"];
            int id = Save(postData, sysMsg);

            if (sysMsg.isPass && id > 0)
            {
                List<int> lstToChildIds = new List<int>();
                string templateName = Request["templateName"];
                string toChildIds = Request["toChildIds"];
                int entityId = id;
                int fromId = ParseHelper.Parse<int>(Request["fromId"]);
                int toId = ParseHelper.Parse<int>(Request["toId"]);
                bool checkData = !(Request["checkData"] == "false");
                bool waitAllChildComplated = !(Request["waitAllChildComplated"] == "false");

                if (!String.IsNullOrWhiteSpace(toChildIds))
                {
                    foreach (string stcid in toChildIds.Split(','))
                    {
                        int tcid = ParseHelper.Parse<int>(stcid);
                        if (tcid > 0)
                        {
                            lstToChildIds.Add(Convert.ToInt32(tcid));
                        }
                    }
                }

                WFTemplate wfTemplate = new WFTemplate(templateName, entityId);

                using (TScope ts = new TScope())
                {
                    if (toId == 0)
                    {
                        sysMsg.Merge(wfTemplate.Run(fromId, checkData));
                    }
                    else
                    {
                        sysMsg.Merge(wfTemplate.Skip(toId, fromId, checkData, waitAllChildComplated, lstToChildIds.ToArray()));
                    }

                    if (!sysMsg.isPass)
                    {
                        ts.Rollback();
                    }
                }

                B2FQuotationDetail b2Detail = new B2FQuotationDetail();
                List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_B2F);
                b2Detail.FillCategoryData(lfc, id);
                html = DetailUIHelper.GenrateCategories(lfc, wfTemplate);
                wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";
            }
            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg,
                Html = html,
                wfStatus = wfStatus
            };
            return Json(jsonResult);
        }
Beispiel #14
0
        private int Save(string postData, SystemMessages sysMsg, bool checkRequired)
        {
            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 commonCategoryName = Convert.ToString(jsonData["commonCategoryName"]);
                string basicInfoCategoryName = Convert.ToString(jsonData["basicInfoCategoryName"]);
                string processFlowCategoryName = Convert.ToString(jsonData["processFlowCategoryName"]);
                string bomCategoryName = Convert.ToString(jsonData["bomCategoryName"]);
                string edmCategoryName = Convert.ToString(jsonData["edmCategoryName"]);
                string specialCategoryName = Convert.ToString(jsonData["specialCategoryName"]);

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

                CostingInputDetail ciDetail = new CostingInputDetail();

                ciDetail.CommonCategory = new FieldCategory(commonCategoryName);
                ciDetail.BasicInfoCategory = new FieldCategory(basicInfoCategoryName);
                ciDetail.ProcessFlowCategory = new FieldCategory(processFlowCategoryName);
                ciDetail.BOMCategory = new FieldCategory(bomCategoryName);
                ciDetail.EDMCategories = FieldCategory.GetCategoryByName(edmCategoryName);
                ciDetail.SpecialCategory = FieldCategory.GetCategoryByName(specialCategoryName);
                ciDetail.YieldData = yieldData;
                ciDetail.FillData(data);
                ciDetail.CheckDataType(sysMsg);

                if (checkRequired)
                {
                    ciDetail.CheckRequired(sysMsg);
                }

                if (sysMsg.isPass)
                {
                    using (TScope ts = new TScope())
                    {
                        try
                        {
                            if (id > 0)
                            {
                                ciDetail.Update(id);
                            }
                            else
                            {
                                id = ciDetail.Add();
                            }
                        }
                        catch (Exception ex)
                        {
                            ts.Rollback();
                            sysMsg.isPass = false;
                            sysMsg.Messages.Add("Error", ex.Message);
                        }
                    }
                }
            }

            return id;
        }
Beispiel #15
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);
 }
 public ActionResult RequestToVendor(string KeyValues)
 {
     SystemMessages sysMsg = new SystemMessages();
     if (!string.IsNullOrEmpty(KeyValues))
     {
         using (TScope ts = new TScope())
         {
             try
             {
                 string[] ids = KeyValues.Split(',');
                 DateTime date = DateTime.Now;
                 if (ids != null && ids.Length > 0)
                 {
                     SCMPriceMasterDetail smd = new SCMPriceMasterDetail();
                     foreach (string id in ids)
                     {
                         if (!smd.CheckIsFree(id))
                         {
                             throw new Exception("Cannot request a data in process!");
                         }
                         smd.CreateNewRequestToVendor(id, date);
                         smd.ChangeRequestStatus(id, SCMPriceMasterDetail.RequestStatus_InProcess);
                     }
                 }
             }
             catch (Exception ex)
             {
                 ts.Rollback();
                 sysMsg.isPass = false;
                 sysMsg.Messages.Add("Error", ex.Message);
             }
         }
     }
     var result = new
     {
         success = sysMsg.isPass,
         message = (sysMsg.isPass ? "" : sysMsg.Messages.ToString())
     };
     return Json(result);
 }
Beispiel #17
0
        public static void UpdateTempToNormal(string tempId, string id)
        {
            string strSql = "SELECT COUNT(*) FROM SGP_FilesForVVI WHERE RelationKey = @TempId";
            if (DbHelperSQL.GetSingle<int>(strSql, new SqlParameter[] { new SqlParameter("@TempId", tempId) }) > 0)
            {
                using (TScope ts = new TScope())
                {
                    strSql = "UPDATE SGP_FilesForVVI SET RelationKey = @RelationKey, Status = 1, Folder = @RelationKey FROM SGP_Files WHERE RelationKey = @TempId";
                    DbHelperSQL.ExecuteSql(strSql, new SqlParameter[]{
                        new SqlParameter("@RelationKey", id),
                        new SqlParameter("@TempId", tempId),
                    });

                    try
                    {
                        FolderRename(tempId, id);
                    }
                    catch
                    {
                        ts.Rollback();
                    }
                }

            }
        }
Beispiel #18
0
        public ActionResult WFRunSkips(string KeyValues, string ToID)
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();

            string toActivityId = ToID;
            int toActId = 0;
            int.TryParse(toActivityId, out toActId);

            if (!String.IsNullOrEmpty(KeyValues))
            {
                string[] ids = KeyValues.Split(',');
                if (ids != null && ids.Length > 0)
                {
                    using (TScope ts = new TScope())
                    {
                        foreach (string id in ids)
                        {
                            if (!String.IsNullOrEmpty(id))
                            {
                                int entityId = 0;
                                if (int.TryParse(id, out entityId))
                                {
                                    try
                                    {
                                        WFTemplate wfTemplate = new WFTemplate("DefaultWF", entityId);
                                        if (RFQManager.IsPendingStatus(entityId, toActId) == false)
                                        {
                                            sysMsg.isPass = false;
                                            sysMsg.Messages.Add("System Exception", "the HitRate Status is Pending, do not allow go to the Closure Status");
                                        }
                                        else
                                        {
                                            sysMsg.Merge(wfTemplate.Skip(toActId));
                                        }
                                        RFQManager.PostRFQToVVI(entityId);
                                    }
                                    catch (Exception ex)
                                    {
                                        sysMsg.isPass = false;
                                        sysMsg.Messages.Add("System Exception", ex.Message);
                                    }
                                }
                                else
                                {
                                    sysMsg.isPass = false;
                                    sysMsg.Messages.Add("ID Error", String.Format("[{0}] is not a valid ID", id));
                                }
                            }
                        }

                        if (!sysMsg.isPass)
                        {
                            ts.Rollback();
                        }
                    }
                }
            }

            return Json(sysMsg);
        }
Beispiel #19
0
        public ActionResult WFRun(string KeyValues)
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();

            if (!String.IsNullOrEmpty(KeyValues))
            {
                string[] ids = KeyValues.Split(',');
                if (ids != null && ids.Length > 0)
                {
                    using (TScope ts = new TScope())
                    {
                        foreach (string id in ids)
                        {
                            if (!String.IsNullOrEmpty(id))
                            {
                                int entityId = 0;
                                if (int.TryParse(id, out entityId))
                                {
                                    try
                                    {
                                        WFTemplate wfTemplate = new WFTemplate("DefaultWF", entityId);
                                        sysMsg.Merge(wfTemplate.Run());
                                    }
                                    catch (Exception ex)
                                    {
                                        sysMsg.isPass = false;
                                        sysMsg.Messages.Add("System Exception", ex.Message);
                                    }
                                }
                                else
                                {
                                    sysMsg.isPass = false;
                                    sysMsg.Messages.Add("ID Error", String.Format("[{0}] is not a valid ID", id));
                                }
                            }
                        }

                        if (!sysMsg.isPass)
                        {
                            ts.Rollback();
                        }
                    }
                }
            }

            return Json(sysMsg);
        }
        public JsonResult SaveOtherData()
        {
            SystemMessages sysMsg = new SystemMessages();
            int id = 0;
            string postData = Request["postData"];

            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"]);
                Int32.TryParse(dataId, out id);
                FieldCategory category = new FieldCategory(Convert.ToString(jsonData["categoryName"]));
                Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;

                using (TScope ts = new TScope())
                {
                    try
                    {
                        CostingOtherDetailData codd = new CostingOtherDetailData(category, data);
                        category.CheckDataType(data, sysMsg);
                        codd.CheckData(sysMsg);

                        if (sysMsg.isPass)
                        {
                            if (id > 0)
                            {
                                codd.Update(id);
                            }
                            else
                            {
                                id = codd.Add();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ts.Rollback();
                        sysMsg.isPass = false;
                        sysMsg.Messages.Add("Error", ex.Message);
                    }
                }
            }

            var jsonResult = new
            {
                DataId = id,
                success = sysMsg.isPass,
                errMessage = sysMsg.MessageString
            };
            return Json(jsonResult);
        }
Beispiel #21
0
        /// <summary>
        /// Supplier RFQ workflow
        /// </summary>
        /// <returns></returns>
        public ActionResult SUPPLIERRFQWFSkip()
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();

            string postData = Request["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 number = Convert.ToString(jsonData["number"]);
            int id = 0;
            WFTemplate wfTemplate;
            string wfStatus = string.Empty;

            using (TScope ts = new TScope())
            {
                bool isOutOfCapability;
                id = SupplierRfqSave(postData, sysMsg, out isOutOfCapability);
                wfTemplate = new WFTemplate("SUPPLIERWF", id, number);
                if (!isOutOfCapability)
                {
                    wfTemplate.FirstActivity.CheckData(sysMsg);
                }

                SkipRFQWFToNextForVVI(id, sysMsg);

                if (!sysMsg.isPass)
                {
                    ts.Rollback();
                }
                else
                {
                    //Send Email To VVI Team
                    wfTemplate.LastActivity.DoAction();
                }
            }

            wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";
            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg,
                wfStatus = wfStatus
            };
            return Json(jsonResult);
        }
        public ActionResult UploadFile()
        {
            string tableKey = Request["tableKey"];
            string pageType = Request["pageType"];
            HttpPostedFileBase file = Request.Files["Filedata"];
            SystemMessages sysMsg = new SystemMessages();
            using (TScope ts = new TScope())
            {
                try
                {
                    DataSet ds = ExcelHelper.ReadExcel(file.InputStream, true);
                    if (ds.Tables.Count > 0)
                    {
                        DateTime date = DateTime.Now;
                        DataTable dt = ds.Tables[0];
                        FieldCategory fc = new FieldCategory(tableKey, pageType);
                        foreach (DataRow dr in dt.Rows)
                        {
                            fc.ClearAllFieldsData();
                            FieldInfoCollecton fields = fc.VisibleFields;
                            Dictionary<string, object> dicData = new Dictionary<string, object>();
                            foreach (DataColumn dc in dt.Columns)
                            {
                                var fi = fields.Where(p => p.DisplayName == dc.ColumnName).SingleOrDefault();
                                if (fi != null)
                                {
                                    dicData.Add(fi.FieldName, dr[dc.ColumnName]);
                                }
                            }

                            if (dicData.Count == 0)
                            {
                                throw new Exception("Upload Error: can not match data.");
                            }
                            else
                            {
                                SCMPriceMasterDetail smd = new SCMPriceMasterDetail(fc, dicData, pageType);
                                fc.CheckDataType(dicData, sysMsg);
                                smd.CheckData(sysMsg);
                                if (sysMsg.isPass)
                                {
                                    smd.InsertUploadFile(date);
                                }
                                else
                                {
                                    ts.Rollback();
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    sysMsg.isPass = false;
                    sysMsg.Messages.Add("Error", ex.Message);
                }
                var result = new
                {
                    success = sysMsg.isPass,
                    errMessage = sysMsg.MessageString
                };
                return Json(result);
            }
        }
Beispiel #23
0
        public ActionResult VVIWFSkip()
        {
            SystemMessages sysMsg = WFHelper.CreateMessages();
            string html = "";
            string wfStatus = "";
            string PDFDIV = "";
            string postData = Request["postData"];
            int id = VVISave(postData, sysMsg);

            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>;
            Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;
            Dictionary<string, object> productiondata = data["24"] as Dictionary<string, object>;

            if (sysMsg.isPass && id > 0)
            {
                List<int> lstToChildIds = new List<int>();
                string templateName = Request["templateName"];
                string toChildIds = Request["toChildIds"];
                int entityId = id;
                int fromId = ParseHelper.Parse<int>(Request["fromId"]);
                int toId = ParseHelper.Parse<int>(Request["toId"]);
                bool checkData = !(Request["checkData"] == "false");
                bool waitAllChildComplated = !(Request["waitAllChildComplated"] == "false");

                if (!String.IsNullOrWhiteSpace(toChildIds))
                {
                    foreach (string stcid in toChildIds.Split(','))
                    {
                        int tcid = ParseHelper.Parse<int>(stcid);
                        if (tcid > 0)
                        {
                            lstToChildIds.Add(Convert.ToInt32(tcid));
                        }
                    }
                }

                WFTemplate wfTemplate = new WFTemplate(templateName, entityId);
                using (TScope ts = new TScope())
                {
                    if (toId == 0)
                    {
                        sysMsg.Merge(wfTemplate.Run(fromId, checkData));
                    }
                    else
                    {
                        sysMsg.Merge(wfTemplate.Skip(toId, fromId, checkData, waitAllChildComplated, lstToChildIds.ToArray()));
                    }

                    if (productiondata.ContainsKey("vendorrfqid") && (toId == 104 || wfTemplate.NextActivity.ID == 104))
                    {

                        if (string.IsNullOrEmpty(productiondata["vendorrfqid"].ToString()) == false)
                        {

                            try
                            {

                                VVIQuotationDetail dm = new VVIQuotationDetail();
                                if (dm.CheckMainRFQStatusByID(id))
                                {
                                    DbHelperSQL.ExecuteSql("exec SP_VVIPostBackSGP @EntityID,@VendorRFQNumber ", new SqlParameter("@EntityID", entityId), new SqlParameter("@VendorRFQNumber", productiondata["vendorrfqid"].ToString()));
                                    sysMsg.isPass = true;
                                }
                                else
                                {
                                    sysMsg.isPass = false;
                                    sysMsg.Messages.Add("Error", "Main RFQ status is not TechnicalCosting stage.");
                                }
                            }
                            catch (Exception ex)
                            {
                                sysMsg.isPass = false;
                                sysMsg.Messages.Add("error", ex.Message);
                            }

                        }
                    }

                    if (!sysMsg.isPass)
                    {
                        ts.Rollback();
                    }
                }

                VVIQuotationDetail b2Detail = new VVIQuotationDetail();
                List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_VVI);
                b2Detail.FillCategoryData(lfc, id);
                html = DetailUIHelper.GenrateCategories(lfc, wfTemplate);
                wfStatus = wfTemplate.Status == WorkflowStatus.Finished ? "Finished" : "";
            }

            var jsonResult = new
            {
                DataId = id,
                SysMsg = sysMsg,
                Html = html,
                PDF = PDFDIV,
                wfStatus = wfStatus
            };
            return Json(jsonResult);
        }
Beispiel #24
0
        /// <summary>
        /// 真正写入数据,不做任何判断
        /// </summary>
        /// <param name="rfqId"></param>
        /// <param name="dicAllTable"></param>
        /// <param name="fields"></param>
        /// <returns></returns>
        public static bool UpdateData(int rfqId, Dictionary<string, Dictionary<string, string>> dicAllTable, FieldInfoCollecton fields)
        {
            string uid = BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid;

            if (dicAllTable.Keys.Contains("SGP_RFQ"))
            {
                dicAllTable.Remove("SGP_RFQ");
            }

            using (TScope ts = new TScope())
            {
                try
                {
                    BI.SGP.BLL.Event.UserChangedEvent uce = new Event.UserChangedEvent(rfqId);
                    uce.DoBefore();

                    string strSql = "";
                    foreach (string tableName in dicAllTable.Keys)
                    {
                        List<SqlParameter> listParames = new List<SqlParameter>();
                        string strField = "";

                        foreach (KeyValuePair<string, string> kvField in dicAllTable[tableName])
                        {
                            if (kvField.Key == "RFQDateIn") continue;
                            if (kvField.Key == "RFQDateOut") continue;
                            if (kvField.Key == "QuoteDateIn") continue;
                            if (kvField.Key == "QuoteDateOut") continue;
                            if (kvField.Key == "PriceDateOut") continue;

                            strField += kvField.Key + "=@" + kvField.Key + ",";
                            if (fields[kvField.Key].DataType == BLL.DataModels.FieldInfo.DATATYPE_DATETIME && String.IsNullOrEmpty(kvField.Value))
                            {
                                listParames.Add(new SqlParameter("@" + kvField.Key, DBNull.Value));
                            }
                            else
                            {
                                if (String.IsNullOrEmpty(kvField.Value.Trim()))
                                {

                                    listParames.Add(new SqlParameter("@" + kvField.Key, DBNull.Value));
                                }
                                else
                                {
                                    listParames.Add(new SqlParameter("@" + kvField.Key, kvField.Value));
                                }
                            }

                        }
                        strField = strField.TrimEnd(',');
                        listParames.Add(new SqlParameter("@RFQID", rfqId));
                        strSql = String.Format("UPDATE SGP_RFQ SET EmployeeID = '{0}', LastUpdate=getdate() WHERE ID = {1};", uid, rfqId);
                        strSql += "UPDATE " + tableName + " SET " + strField + " WHERE RFQID = @RFQID";

                        DbHelperSQL.ExecuteSql(strSql, listParames.ToArray());

                    }

                    UpdateSpecialFields(rfqId);

                    strSql = "Insert Into SGP_RFQHistory select *,getdate() from v_sgp where RFQID=@RFQID";
                    DbHelperSQL.ExecuteSql(strSql, new SqlParameter("@RFQID", rfqId));

                    uce.DoAfter();
                    return true;
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    throw ex;
                }
            }
            return true;
        }
Beispiel #25
0
        private int Save(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_B2F);

                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
                        {
                            BI.SGP.BLL.Models.B2FComputedField aftercomputeddata = new B2FComputedField();
                            aftercomputeddata.Data = data;

                            B2FQuotationDetail dm = new B2FQuotationDetail(lfc, aftercomputeddata.SetComputedValue());
                            if (operation == B2FQuotationDetail.OPERATION_REQUOTE)
                            {
                                id = dm.ReQuote();
                            }
                            else if (operation == B2FQuotationDetail.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;
        }
Beispiel #26
0
        public static bool __Insert(ref int rfqId, Dictionary<string, Dictionary<string, string>> dicAllTable, FieldInfoCollecton fields)
        {
            string uid = BI.SGP.BLL.Utils.AccessControl.CurrentLogonUser.Uid;

            string strSql = string.Empty;
            //string strSql = "INSERT INTO SGP_RFQ(Number, EmployeeID) VALUES(dbo.fx_newGPRFQ('" + uid + "'), '" + uid + "');SELECT @@IDENTITY";

            using (TScope ts = new TScope())
            {
                try
                {
                    rfqId = CreateNewRFQID(uid);
                    //string tempId = Convert.ToString(DbHelperSQL.GetSingle(strSql));
                    string tempId = rfqId.ToString();

                    //int.TryParse(tempId, out rfqId);
                    if (rfqId > 0)
                    {
                        if (dicAllTable.Keys.Contains("SGP_RFQ"))
                        {
                            dicAllTable.Remove("SGP_RFQ");
                        }

                        foreach (string tableName in dicAllTable.Keys)
                        {
                            List<SqlParameter> listParames = new List<SqlParameter>();
                            string strField = "RFQID,";
                            string strValue = "@RFQID,";
                            listParames.Add(new SqlParameter("@RFQID", rfqId));
                            foreach (KeyValuePair<string, string> kvField in dicAllTable[tableName])
                            {
                                strField += kvField.Key + ",";
                                strValue += "@" + kvField.Key + ",";
                                if (fields[kvField.Key].DataType == BLL.DataModels.FieldInfo.DATATYPE_DATETIME && String.IsNullOrEmpty(kvField.Value))
                                {
                                    listParames.Add(new SqlParameter("@" + kvField.Key, DBNull.Value));
                                }
                                else
                                {
                                    if (String.IsNullOrEmpty(kvField.Value.Trim()))
                                    {

                                        listParames.Add(new SqlParameter("@" + kvField.Key, DBNull.Value));
                                    }
                                    else
                                    {
                                        listParames.Add(new SqlParameter("@" + kvField.Key, kvField.Value));
                                    }
                                }

                            }
                            strField = strField.TrimEnd(',');
                            strValue = strValue.TrimEnd(',');

                            strSql = "INSERT INTO " + tableName + "(" + strField + ") VALUES(" + strValue + ")";

                            DbHelperSQL.ExecuteSql(strSql, listParames.ToArray());
                        }

                        UpdateSpecialFields(rfqId);

                        strSql = "Insert Into SGP_RFQHistory select *,getdate() from v_sgp where RFQID=@RFQID";
                        DbHelperSQL.ExecuteSql(strSql, new SqlParameter("@RFQID", tempId));

                        List<SqlParameter> Params = new List<SqlParameter>() { new SqlParameter("@RFQID", tempId), new SqlParameter("@UID", uid) };
                        strSql = "Insert into [SYS_WFProcessLog] select @RFQID,1,0,1,getdate(),@UID,NULL";
                        DbHelperSQL.ExecuteSql(strSql, Params.ToArray());

                        return true;
                    }
                    else
                    {
                        ts.Rollback();
                    }
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    throw ex;
                }
            }

            return false;
        }
Beispiel #27
0
        public JsonResult SaveData()
        {
            SystemMessages sysMsg = new SystemMessages();
            int id = 0;
            string postData = Request["postData"];

            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"]);
                Int32.TryParse(dataId, out id);
                FieldCategory category = new FieldCategory(Convert.ToString(jsonData["categoryName"]));
                Dictionary<string, object> data = jsonData["data"] as Dictionary<string, object>;

                if (id == 0)
                {
                    data["CreatorName"] = AccessControl.CurrentLogonUser.Name;
                    data["CreationTime"] = DateTime.Now;
                }

                using (TScope ts = new TScope())
                {
                    try
                    {
                        CostingPeriodDetail cpd = new CostingPeriodDetail(category, data);
                        category.CheckDataType(data, sysMsg);
                        cpd.CheckData(sysMsg);

                        if (sysMsg.isPass)
                        {
                            if (id > 0)
                            {
                                cpd.Update(id);
                            }
                            else
                            {
                                id = cpd.Add();
                            }

                            if (Convert.ToString(data["Status"]) == "Active")
                            {
                                SetActiveToClose(id);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ts.Rollback();
                        sysMsg.isPass = false;
                        sysMsg.Messages.Add("Error", ex.Message);
                    }
                }
            }

            var jsonResult = new
            {
                DataId = id,
                success = sysMsg.isPass,
                errMessage = sysMsg.MessageString
            };
            return Json(jsonResult);
        }
Beispiel #28
0
        public static bool SaveforCustomerProfileExcel(DataRow dr, out string msg)
        {
            msg = "";
            Dictionary<string, Dictionary<string, string>> dicAllTable = new Dictionary<string, Dictionary<string, string>>();
            FieldInfoCollecton fields = FieldCategory.GetAllFields(FieldCategory.Category_TYPE_CUSTOMERPROFILE);

            for (int i = 0; i < dr.Table.Columns.Count; i++)
            {
                string columnName = dr.Table.Columns[i].ColumnName;
                BI.SGP.BLL.DataModels.FieldInfo fi = fields.Find(t => string.Compare(t.FieldName, columnName, true) == 0);
                fi.DataValue = dr[i];

                if (fi != null && !String.IsNullOrEmpty(fi.TableName))
                {
                    string tableName = fi.TableName.ToUpper();
                    if (dicAllTable.ContainsKey(tableName))
                    {
                        dicAllTable[tableName].Add(columnName, Convert.ToString(dr[i]));
                    }
                    else
                    {
                        Dictionary<string, string> dic = new Dictionary<string, string>();
                        dic.Add(columnName, Convert.ToString(dr[i]));
                        dicAllTable.Add(tableName, dic);
                    }
                }
            }
            using (TScope ts = new TScope())
            {
                try
                {
                    if (CheckNameOnly(Convert.ToString(dr["Customer"])))
                    {
                        InsertOperation(dicAllTable);
                    }
                    else
                    {
                        UpdateOperation(Convert.ToString(dr["Customer"]), dicAllTable);
                    }
                }
                catch (Exception ex)
                {
                    ts.Rollback();
                    msg = string.Format("Error:" + ex.Message);
                    return false;
                }
            }
            msg = "Uploaded successfully";
            return true;
        }