public List <CostDetailInformation> GetAllDetailCostcerter(WS_Dept_type type) { var data = Soap.web_cost_basic(type.ToString()); if (data.Rows != null && data.Rows.Count > 0) { List <CostDetailInformation> rtn = new List <CostDetailInformation>() { }; foreach (DataRow item in data.Rows) { rtn.Add(new CostDetailInformation() { CostCode = item["costcode"].ToString().Trim(), CostName = item["costdesc"].ToString().Trim(), Sick = item["sick"].ToString().Trim(), ECostDesc = item["ecostdesc"].ToString().Trim(), ESick = item["esick"].ToString().Trim(), DeptType = EnumHelper.GetEnumByName <WS_Dept_type>(item["dept_type"].ToString()), OpdFlag = EnumHelper.GetEnumByName <WS_Opd_flag>(item["opd_flag"].ToString()), WebFlag = item["web_flag"].ToString() }); } return(rtn); } else { return(null); } }
public JsonResult GetDeptInfo(string CostCode) { WanFang.BLL.WebService_Manage service = new WanFang.BLL.WebService_Manage(); WS_Dept_type depttype = EnumHelper.GetEnumByName <WS_Dept_type>(CostCode); var Dept = service.GetAllDetailCostcerter(depttype); WS_DeptModel result = new WS_DeptModel(); result.DeptList = Dept; result.setMessage("Done"); return(Json(result, JsonRequestBehavior.DenyGet)); }
public JsonResult SaveNewsData(NewsData_Info data) { //data.DeptName = getDeptName(sessionData.trading.Dept.Value); ResultBase result = new ResultBase(); result.setMessage("Done"); if (string.IsNullOrEmpty(data.Title)) { result.setErrorMessage("標題不得為空白"); } if (string.IsNullOrEmpty(data.Author)) { result.setErrorMessage("發表者不得為空白"); } if (string.IsNullOrEmpty(data.Keyword)) { result.setErrorMessage("後台關鍵字不得為空白"); } if (string.IsNullOrEmpty(data.ContentBody)) { result.setErrorMessage("內容不得為空白"); } if (result.JsonReturnCode > -1) { if (data.IsActive == 1) { //審核專用 var verdata = NewsDataMan.GetBySN(data.NewsId); verdata.IsActive = 1; verdata.VerifiedDate = DateTime.Now; NewsDataMan.Update(verdata); return(Json(result, JsonRequestBehavior.DenyGet)); } else { //一但有任何異動,自動下架 data.IsActive = 0; } data.LastUpdate = DateTime.Now; data.LastUpadtor = sessionData.trading.LoginId; var olddata = NewsDataMan.GetBySN(data.NewsId); checkUploadfiles(data, olddata); if (data.DeptName.Length == 1) { //DeptName is real DeptCode data.DeptCode = data.DeptName; //Get DeptName from DeptCode data.DeptName = EnumHelper.GetEnumDescription <WS_Dept_type>(EnumHelper.GetEnumByName <WS_Dept_type>(data.DeptCode)); } else { //Get DeptCode from DeptName var allenum = Enum.GetValues(typeof(WS_Dept_type)).Cast <WS_Dept_type>(); var deptobj = allenum.Where(x => EnumHelper.GetEnumDescription <WS_Dept_type>(x) == data.DeptName).FirstOrDefault(); if (deptobj != null) { data.DeptCode = deptobj.ToString(); } } //get costid from costname WS_Dept_type depttype = EnumHelper.GetEnumByName <WS_Dept_type>(data.DeptCode); var CostObject = new WebService_Manage().GetAllDetailCostcerter(depttype).Where(x => data.Cost.Trim() == x.CostName.Trim()).FirstOrDefault(); if (CostObject != null) { data.CostId = CostObject.CostCode; if (data.NewsId > 0) { NewsDataMan.Update(data); result.setMessage(data.NewsId.ToString()); } else { var newId = NewsDataMan.Insert(data); result.setMessage(newId.ToString()); } } else { result.setException(new Exception(string.Format("查無科別代碼({0})", data.Cost)), "SaveNewsData"); } } return(Json(result, JsonRequestBehavior.DenyGet)); }
private string getDeptName(WS_Dept_type DeptType) { return(EnumHelper.GetEnumDescription <WS_Dept_type>(DeptType)); }