public HttpResponseMessage GetPlan() { ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; T_Planing_SpecPODTO dto = null; try { var context = HttpContext.Current; dto = ConvertX.GetReqeustForm <T_Planing_SpecPODTO>(); bal = new T_Planing_SpecPOBAL(); logger.debug("View dto:" + dto.ToString()); dto = bal.FindByObjHistory(dto); response.statusCode = true; response.data = dto; } catch (Exception ex) { logger.error("View error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
public HttpResponseMessage UpdatePlan() { bal = new T_Planing_SpecPOBAL(); ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; try { var context = HttpContext.Current; T_Planing_SpecPODTO dto = ConvertX.GetReqeustForm <T_Planing_SpecPODTO>(); string UserID = context.Request.Form["UserID"]; if (ObjUtil.isEmpty(UserID)) { throw new Exception("UserID is require"); } dto.CreateBy = UserID; dto.UpdateBy = UserID; logger.debug("UpdatePlan dto:" + dto.ToString()); response.statusCode = bal.UpdateNewPlan(dto); } catch (Exception ex) { logger.error("UpdatePlan error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
public T_Planing_SpecPODTO FindByObjHistory(object data) { List <SqlParameter> parameterList = new List <SqlParameter>(); obj = new T_Planing_SpecPODTO(); dataTable = null; string procName = "sp_T_Planing_SpecPO_FindByPK"; try { dataTable = new DataTable(); adapter = new SqlDataAdapter(); SqlConnection conn = OpenConnection(); if (data != null) { parameterList.AddRange(GetParameters(procName, data).ToArray()); } command = new SqlCommand(procName, conn); command.CommandType = CommandType.StoredProcedure; if (data != null) { command.Parameters.AddRange(parameterList.ToArray()); } using (SqlDataReader reader = command.ExecuteReader()) { obj = ConvertX.GetListFromDataReader <T_Planing_SpecPODTO>(reader).ToList()[0]; obj.SpecSDate = ConvertX.DDMMYY(obj.SpecSDate); obj.SpecEDate = ConvertX.DDMMYY(obj.SpecEDate); obj.ActualSpecEDate = ConvertX.DDMMYY(obj.ActualSpecEDate); obj.POSDate = ConvertX.DDMMYY(obj.POSDate); obj.POEDate = ConvertX.DDMMYY(obj.POEDate); obj.ActualPOEDate = ConvertX.DDMMYY(obj.ActualPOEDate); obj.ActionSDate = ConvertX.DDMMYY(obj.ActionSDate); obj.ActionEDate = ConvertX.DDMMYY(obj.ActionEDate); obj.ActualActionEDate = ConvertX.DDMMYY(obj.ActualActionEDate); reader.NextResult(); obj.History = ConvertX.GetListFromDataReader <T_Planing_SpecPO_HistoryDTO>(reader).ToList(); } } catch (Exception ex) { } finally { CloseConnection(); } return(obj); }
public override bool Add(object data) { try { obj = (T_Planing_SpecPODTO)data; OpenConnection(); /* if (obj.SpecSDate != null && obj.SpecEDate != null) * { * obj.SpecSDate = ConvertX.MMddYY(obj.SpecSDate); * obj.SpecEDate = ConvertX.MMddYY(obj.SpecEDate); * } * * * if (obj.POSDate != null && obj.POEDate != null) * { * obj.POSDate = ConvertX.MMddYY(obj.POSDate); * obj.POEDate = ConvertX.MMddYY(obj.POEDate); * } * * * if (obj.ActionSDate != null && obj.ActionEDate != null) * { * obj.ActionSDate = ConvertX.MMddYY(obj.ActionSDate); * obj.ActionEDate = ConvertX.MMddYY(obj.ActionEDate); * }*/ /* if (obj.EventDate != null && obj.EventDate != null) * { * obj.EventDate = ConvertX.MMddYY(obj.EventDate); * }*/ isCan = ExcecuteNoneQuery("sp_T_Planing_SpecPO_Insert", obj); CloseConnection(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(isCan); }
public bool UpdateNewPlan(object dto) { T_PlaningDAO planDAO = new T_PlaningDAO(); T_Planing_SpecPODTO planSpecPODTO = new T_Planing_SpecPODTO(); T_PlaningDTO newPlanDTO = new T_PlaningDTO(); PlanType type = new PlanType(); bool isCanupdate = false; try { planSpecPODTO = (T_Planing_SpecPODTO)dto; newPlanDTO.PID = planSpecPODTO.PID; newPlanDTO = planDAO.FindByPK(newPlanDTO); if (planSpecPODTO.PlanType == "2") { type = PlanType.Spec; } else if (planSpecPODTO.PlanType == "3") { type = PlanType.PO; } else if (planSpecPODTO.PlanType == "4") { type = PlanType.Action; } newPlanDTO = PlanUtils.ShipPlan(newPlanDTO, planSpecPODTO.StartDate, planSpecPODTO.EndDate, type); newPlanDTO.PlanType = planSpecPODTO.PlanType; newPlanDTO.EditNote = planSpecPODTO.EditNote; newPlanDTO.UpdateBy = planSpecPODTO.UpdateBy; isCanupdate = dao.UpdateNewPlan(newPlanDTO); } catch (Exception ex) { Log((dto as T_Planing_SpecPODTO).Page, "Error", ex.ToString()); } return(isCanupdate); }
public override bool Add(object dto) { bool isCan = false; try { T_Planing_SpecPODTO obj = dto as T_Planing_SpecPODTO; if (obj.SpecSDate != null && obj.SpecEDate != null) { obj.SpecSDate = ConvertX.MMddYY(obj.SpecSDate); obj.SpecEDate = ConvertX.MMddYY(obj.SpecEDate); } if (obj.POSDate != null && obj.POEDate != null) { obj.POSDate = ConvertX.MMddYY(obj.POSDate); obj.POEDate = ConvertX.MMddYY(obj.POEDate); } if (obj.ActionSDate != null && obj.ActionEDate != null) { obj.ActionSDate = ConvertX.MMddYY(obj.ActionSDate); obj.ActionEDate = ConvertX.MMddYY(obj.ActionEDate); } if (obj.EventDate != null && obj.EventDate != null) { obj.EventDate = ConvertX.MMddYY(obj.EventDate); } isCan = dao.Add(obj); } catch (Exception ex) { Log((dto as T_Planing_SpecPODTO).Page, "Error", ex.ToString()); } return(isCan); }
public HttpResponseMessage Delete() { bal = new T_Planing_SpecPOBAL(); ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; try { var context = HttpContext.Current; T_Planing_SpecPODTO dto = ConvertX.GetReqeustForm <T_Planing_SpecPODTO>(); logger.debug("Delete dto:" + dto.ToString()); response.statusCode = bal.Delete(dto); } catch (Exception ex) { logger.error("Delete error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
public HttpResponseMessage Add() { T_Planing_SpecPODTO dto = null; ResposeType response = new ResposeType(); HttpResponseMessage mapMessage = null; try { var context = HttpContext.Current; List <ResponseDTO> responseList = Validate(context); if (responseList.Count == 0) { dto = ConvertX.GetReqeustForm <T_Planing_SpecPODTO>(); bal = new T_Planing_SpecPOBAL(); string UserID = context.Request.Form["UserID"]; if (ObjUtil.isEmpty(UserID)) { throw new Exception("UserID is require"); } dto.CreateBy = UserID; dto.UpdateBy = UserID; string currentDate = string.Format("{0}/{1}/{2}", DateTime.Now.Day.ToString("##00") , DateTime.Now.Month.ToString("##00") , DateTime.Now.Year.ToString("####0000")); string startDate = dto.EventDate; string endDate = dto.EventDate; if (dto.PlanType == "2") // spec { dto.SpecSDate = startDate; dto.SpecEDate = endDate; } else if (dto.PlanType == "3") // PO { dto.POSDate = startDate; dto.POEDate = endDate; } else if (dto.PlanType == "4") // Action { dto.ActionSDate = startDate; dto.ActionEDate = endDate; } logger.debug("Add dto:" + dto.ToString()); response.statusCode = bal.Add(dto); response.statusText = "ADD"; } else { response.statusCode = false; response.statusText = "Validate fail"; response.data = responseList; } } catch (Exception ex) { logger.error("Add error:" + ex.ToString()); response.statusText = ex.ToString(); } mapMessage = Request.CreateResponse(HttpStatusCode.OK, response); return(mapMessage); }
public List <ResponseDTO> Validate(HttpContext context) { T_Planing_SpecPODTO dto = null; DateTime activeDate = new DateTime(); DateTime lastDate = new DateTime(); DateTime lastSpecDate = new DateTime(); DateTime lastPODate = new DateTime(); DateTime lastActionDate = new DateTime(); double lastComplete = 0; T_Planing_SpecPOBAL bal = new T_Planing_SpecPOBAL(); List <ResponseDTO> reponseList = new List <ResponseDTO>(); T_Planing_SpecPODTO orgDto = null; ResponseDTO responseDto = null; dto = ConvertX.GetReqeustForm <T_Planing_SpecPODTO>(); activeDate = ConvertX.ToDate(ConvertX.MMddYY(dto.EventDate)); orgDto = bal.FindByCurrentStatus(dto); logger.debug("Validate orgDto:" + orgDto.ToString()); if (orgDto != null) { lastSpecDate = ConvertX.ToDate(orgDto.SpecEDate); lastPODate = ConvertX.ToDate(orgDto.POEDate); lastActionDate = ConvertX.ToDate(orgDto.ActionEDate); if (dto.PlanType == "2") // spec { lastDate = lastSpecDate; lastComplete = ConvertX.ToDouble(orgDto.SpecComplete); } else if (dto.PlanType == "3") // PO { lastDate = lastPODate; lastComplete = ConvertX.ToDouble(orgDto.POComplete); } else if (dto.PlanType == "4") // Action { lastDate = lastActionDate; lastComplete = ConvertX.ToDouble(orgDto.ActionComplete); } if (activeDate <= lastDate) { responseDto = new ResponseDTO(); responseDto.status = false; responseDto.text = "Date must more than " + string.Format("{0}/{1}/{2}", lastDate.Day, lastDate.Month, lastDate.Year) + ""; responseDto.classElement = "txtEventDate"; reponseList.Add(responseDto); } if (dto.PlanType == "3" && activeDate.Year <= lastSpecDate.Year && ConvertX.GetMonthWeekNumberOfYear(activeDate) <= ConvertX.GetMonthWeekNumberOfYear(lastSpecDate)) { responseDto = new ResponseDTO(); responseDto.status = false; responseDto.text = "PO week more than Spec week (" + string.Format("{0}/{1}/{2}", lastSpecDate.Day, lastSpecDate.Month, lastSpecDate.Year) + ")"; responseDto.classElement = "txtEventDate"; reponseList.Add(responseDto); } if (dto.PlanType == "4" && activeDate.Year <= lastPODate.Year && ConvertX.GetMonthWeekNumberOfYear(activeDate) <= ConvertX.GetMonthWeekNumberOfYear(lastPODate)) { responseDto = new ResponseDTO(); responseDto.status = false; responseDto.text = "Action week more than PO week (" + string.Format("{0}/{1}/{2}", lastPODate.Day, lastPODate.Month, lastPODate.Year) + ")"; responseDto.classElement = "txtEventDate"; reponseList.Add(responseDto); } if (dto.PlanType == "4" && activeDate.Year <= lastSpecDate.Year && ConvertX.GetMonthWeekNumberOfYear(activeDate) <= ConvertX.GetMonthWeekNumberOfYear(lastSpecDate)) { responseDto = new ResponseDTO(); responseDto.status = false; responseDto.text = "Action week more than Spec week (" + string.Format("{0}/{1}/{2}", lastSpecDate.Day, lastSpecDate.Month, lastSpecDate.Year) + ")"; responseDto.classElement = "txtEventDate"; reponseList.Add(responseDto); } if (ConvertX.ToDouble(dto.Complete) < lastComplete) { responseDto = new ResponseDTO(); responseDto.status = false; responseDto.text = "Value more than " + lastComplete.ToString() + ""; responseDto.classElement = "txtComplete"; reponseList.Add(responseDto); } } return(reponseList); }