// // GET: /B2F/ public ActionResult Detail(string RFQID) { int dataId = ParseHelper.Parse<int>(RFQID); WFTemplate template = new WFTemplate(2, dataId); List<FieldCategory> lfc = FieldCategory.GetMasterCategorys(FieldCategory.Category_TYPE_B2F); if (dataId > 0) { B2FQuotationDetail b2Detail = new B2FQuotationDetail(); b2Detail.FillCategoryData(lfc, dataId); } ViewBag.WFTemplate = template; ViewBag.Categories = lfc; ViewBag.DataId = dataId; return View(); }
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; }
public ActionResult SaveData() { SystemMessages sysMsg = new SystemMessages(); string html = ""; string wfStatus = ""; int id = 0; string postData = Request["postData"]; id = Save(postData, sysMsg); if (id > 0 && sysMsg.isPass) { WFTemplate wfTemplate = new WFTemplate(2, id); 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); }
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); }
public ActionResult B2FLoadExcel() { DataTable dt = new DataTable(); string message = string.Empty; bool flag = SaveAndReadFile(out dt, out message); DataSet ds = dt.DataSet; if (flag == true && dt != null) { DataTable mainTable = ds.Tables["Primary"]; FieldInfoCollecton fields = FieldCategory.GetAllFields(FieldCategory.Category_TYPE_FPC); ModelHandler<object>.ColumnNameToFieldName(dt, fields); if (!dt.Columns.Contains("Message")) dt.Columns.Add("Message", typeof(string)); if (!dt.Columns.Contains("RFQID")) dt.Columns.Add("RFQID", typeof(string)); if (!dt.Columns.Contains("Number")) dt.Columns.Add("Number", typeof(string)); if (!dt.Columns.Contains("ExtNumber")) dt.Columns.Add("ExtNumber", typeof(string)); List<FieldCategory> categories = FieldCategory.GetCategorys(FieldCategory.Category_TYPE_FPC); foreach (DataRow dr in mainTable.Rows) { try { int dataId = 0; string relationValue = ""; Dictionary<string, DataRow[]> dicSubData = new Dictionary<string, DataRow[]>(); foreach (FieldCategory fc in categories) { fc.ClearFieldsData(); } if (mainTable.Columns.Contains("Number")) { relationValue = Convert.ToString(dr["Number"]); } for (int i = 0; i < ds.Tables.Count; i++) { string tableName = ds.Tables[i].TableName; if (String.Compare(tableName, "DataSource", true) != 0 && String.Compare(tableName, "Primary", true) != 0) { DataTable subdt = ds.Tables[i]; DataRow[] subDrs = null; if (!String.IsNullOrEmpty(relationValue)) { subDrs = subdt.Select(String.Format("[Internal RFQ Number]='{0}'", relationValue)); } else { subDrs = subdt.Select("1=1"); } if (subDrs != null && subDrs.Length > 0) { dicSubData.Add(tableName, subDrs); } } } B2FQuotationDetail dm = new B2FQuotationDetail(categories, dr, dicSubData); if (!String.IsNullOrEmpty(relationValue)) { string sSql = "SELECT ID FROM SGP_RFQ WHERE ExtNumber = @ExtNumber and TemplateID=2"; dataId = DbHelperSQL.GetSingle<int>(sSql, new SqlParameter("@ExtNumber", dr["Number"])); } string sql = "select ID,Number,ExtNumber from SGP_RFQ where ID=@ID"; if (dataId > 0) { DataSet sgpds = DbHelperSQL.Query(sql, new SqlParameter("@ID", dataId)); if (sgpds.Tables.Count>0 && dt.Rows.Count > 0) { dr["RFQID"] = sgpds.Tables[0].Rows[0]["ID"]; dr["Number"] = sgpds.Tables[0].Rows[0]["Number"]; dr["ExtNumber"] = sgpds.Tables[0].Rows[0]["ExtNumber"]; } dm.Update(dataId); } else { dataId = dm.Add(); DataSet sgpds = DbHelperSQL.Query(sql, new SqlParameter("@ID", dataId)); if (sgpds.Tables.Count > 0 && dt.Rows.Count > 0) { dr["RFQID"] = sgpds.Tables[0].Rows[0]["ID"]; dr["Number"] = sgpds.Tables[0].Rows[0]["Number"]; dr["ExtNumber"] = sgpds.Tables[0].Rows[0]["ExtNumber"]; } } } catch (Exception ex) { dr["Message"] = ex.Message; } } dt.Columns["RFQID"].SetOrdinal(0); dt.Columns["Message"].SetOrdinal(1); dt.Columns["Number"].SetOrdinal(2); dt.Columns["ExtNumber"].SetOrdinal(3); 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; return View("~/Views/B2F/ImportExcel.cshtml"); }