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); }
private void UpdateMainDataStatus(string id) { SCMPriceMasterDetail smd = new SCMPriceMasterDetail(); int mainId = smd.GetMainId(id); if (mainId > 0) { smd.UpdateMainQuoteRecord(mainId, id); smd.ChangeRequestStatus(mainId.ToString(), SCMPriceMasterDetail.RequestStatus_Free); } }
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); } }
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); }
public FileResult ExportReport() { string categoryName = Request.QueryString["categoryName"]; SCMPriceMasterDetail smd = new SCMPriceMasterDetail(); DataSet ds = smd.GetReportData(Request, categoryName); if (ds != null && ds.Tables.Count > 0) { string tempFile = ExcelHelper.DataSetToExcel(ds, RenderType.Horizontal); return File(tempFile, "application/ms-excel", "PriceMasterReport_" + DateTime.Now.ToString("yyyyMMddHHmmssffff") + ".xlsx"); } return null; }