public int UpdateRequestDetail(RequestDetail rd) { return(requestDetailsDAO.UpdateRequestDetail(rd)); }
//add RequestDetail with empId , reqDet and status public static RequestDetailVM AddReqDet(int empId, string itemCode, int reqQty, string status) { using (SA46Team08ADProjectContext entities = new SA46Team08ADProjectContext()) { RequestDetailVM rvm = new RequestDetailVM(); if (status == "Unsubmitted") { List <RequestVM> requestlists = RequestBL.GetReq(empId, status); RequestVM request = new RequestVM(); if (requestlists.Count == 0) { request = RequestBL.AddReq(empId, status); } else { request = requestlists[0]; } int reqId = request.ReqId; List <RequestDetail> rdList = entities.RequestDetails.Where(x => x.ReqId == reqId).ToList(); bool exist = false; for (int i = 0; i < rdList.Count; i++) { if (rdList[i].ItemCode == itemCode) { exist = true; rdList[i].ReqQty = rdList[i].ReqQty + reqQty; entities.SaveChanges(); rvm.ReqId = rdList[i].ReqId; rvm.ReqLineNo = rdList[i].ReqLineNo; rvm.ItemCode = rdList[i].ItemCode; rvm.ReqQty = rdList[i].ReqQty; rvm.AwaitQty = rdList[i].AwaitQty; rvm.FulfilledQty = rdList[i].FulfilledQty; } } if (exist == false) { RequestDetail rd = new RequestDetail(); rd.ReqId = reqId; rvm.ReqId = rd.ReqId; if (rdList.Count == 0) { rd.ReqLineNo = 1; } else { rd.ReqLineNo = rdList[rdList.Count - 1].ReqLineNo + 1; } rvm.ReqLineNo = rd.ReqLineNo; rd.ItemCode = itemCode; rvm.ItemCode = rd.ItemCode; rd.ReqQty = reqQty; rvm.ReqQty = rd.ReqQty; rd.AwaitQty = 0; rvm.AwaitQty = rd.AwaitQty; rd.FulfilledQty = 0; rvm.FulfilledQty = rd.FulfilledQty; entities.RequestDetails.Add(rd); entities.SaveChanges(); } } else if (status == "Bookmarked") { List <RequestVM> requestlists = RequestBL.GetReq(empId, status); RequestVM request = new RequestVM(); if (requestlists.Count == 0) { request = RequestBL.AddReq(empId, status); } else { request = requestlists[0]; } int reqId = request.ReqId; List <RequestDetail> rdList = entities.RequestDetails.Where(x => x.ReqId == reqId).ToList(); bool exist = false; for (int i = 0; i < rdList.Count; i++) { if (rdList[i].ItemCode == itemCode) { exist = true; rvm.ReqId = rdList[i].ReqId; rvm.ReqLineNo = rdList[i].ReqLineNo; rvm.ItemCode = rdList[i].ItemCode; rvm.ReqQty = rdList[i].ReqQty; rvm.AwaitQty = rdList[i].AwaitQty; rvm.FulfilledQty = rdList[i].FulfilledQty; } } if (exist == false) { RequestDetail rd = new RequestDetail(); rd.ReqId = reqId; rvm.ReqId = rd.ReqId; if (rdList.Count == 0) { rd.ReqLineNo = 1; } else { rd.ReqLineNo = rdList[rdList.Count - 1].ReqLineNo + 1; } rvm.ReqLineNo = rd.ReqLineNo; rd.ItemCode = itemCode; rvm.ItemCode = rd.ItemCode; rd.ReqQty = 0; rvm.ReqQty = rd.ReqQty; rd.AwaitQty = 0; rvm.AwaitQty = rd.AwaitQty; rd.FulfilledQty = 0; rvm.FulfilledQty = rd.FulfilledQty; entities.RequestDetails.Add(rd); entities.SaveChanges(); } } return(rvm); } }
protected void Page_Load(object sender, EventArgs e) { RequestDetail.BindData(RequestServices.GetById(RequestID).WrapInList()); }
private RequestDetail GetRequestDetail(HttpContext context, RequestInfo request) { RequestDetail model = ModelCreator.CreateRequestDetail(); if (context.Request != null) { model.Id = context.GetUniqueId(); model.RequestId = request.Id; Dictionary <string, string> cookies = context.Request.Cookies.ToList().ToDictionary(x => x.Key, x => x.Value); if (cookies != null && cookies.Count > 0) { model.Cookie = JsonConvert.SerializeObject(cookies); } Dictionary <string, string> headers = context.Request.Headers.ToList().ToDictionary(x => x.Key, x => x.Value.ToString()); if (headers != null && headers.Count > 0) { model.Header = HttpUtility.HtmlDecode(JsonConvert.SerializeObject(headers)); } if (context.Items.ContainsKey(BasicConfig.HttpReportsGlobalException)) { Exception ex = context.Items[BasicConfig.HttpReportsGlobalException] as Exception; if (ex != null) { model.ErrorMessage = ex.Message; model.ErrorStack = HttpUtility.HtmlDecode(ex.StackTrace); } context.Items.Remove(BasicConfig.HttpReportsGlobalException); } if (context.Items.ContainsKey(BasicConfig.HttpReportsRequestBody)) { string requestBody = context.Items[BasicConfig.HttpReportsRequestBody] as string; if (requestBody != null) { model.RequestBody = requestBody; } context.Items.Remove(BasicConfig.HttpReportsRequestBody); } if (context.Items.ContainsKey(BasicConfig.HttpReportsResponseBody)) { string responseBody = context.Items[BasicConfig.HttpReportsResponseBody] as string; if (responseBody != null) { model.ResponseBody = responseBody; } context.Items.Remove(BasicConfig.HttpReportsResponseBody); } model.CreateTime = context.Items[BasicConfig.ActiveTraceCreateTime].ToDateTime(); model.Scheme = context.Request.Scheme; model.QueryString = HttpUtility.UrlDecode(context.Request.QueryString.Value); } return(model); }
protected void btnAddToRequest_Click(object sender, EventArgs e) { if (Page.IsValid) { //add item from existing database if (Request.QueryString["REQUESTCODE"] != null) { if ((string)Request.QueryString["REQUESTCODE"] != "") { RequestDetail requestDetail = null; if (!String.IsNullOrEmpty(tbxQuantity.Text)) { requestDetail = new RequestDetail(); requestDetail.RequestCode = (string)Request.QueryString["REQUESTCODE"]; requestDetail.ItemCode = (string)Request.QueryString["ItemCode"]; requestDetail.Quantity = requestDetail.RemainingQuant = Convert.ToInt32(tbxQuantity.Text); //newItem = new RequestDTO(lblItemCode.Text, lblCategory.Text, lblDescription.Text, Convert.ToInt32(tbxQuantity.Text)); //addItem.Add(newItem); //Session["ItemDetails"] = addItem; } else if (rdlQuantity.SelectedItem.Selected) { requestDetail = new RequestDetail(); requestDetail.RequestCode = (string)Request.QueryString["REQUESTCODE"]; requestDetail.ItemCode = (string)Request.QueryString["ItemCode"]; requestDetail.Quantity = requestDetail.RemainingQuant = Convert.ToInt32(rdlQuantity.SelectedItem.Text); //newItem = new RequestDTO(lblItemCode.Text, lblCategory.Text, lblCategory.Text, Convert.ToInt32(rdlQuantity.SelectedItem.Text)); //addItem.Add(newItem); //Session["ItemDetails"] = addItem; } if (requestDetail != null) { RequestDetail existingRequestDetail = ec.GetRequestDetail(requestDetail.RequestCode, requestDetail.ItemCode); if (existingRequestDetail == null) { ec.AddRequestDetail(requestDetail); } else { existingRequestDetail.Quantity += requestDetail.Quantity; existingRequestDetail.RemainingQuant += requestDetail.RemainingQuant; ec.UpdateRequestDetail(existingRequestDetail); } } } } else { //add item to new request List <RequestDTO> addItem = (List <RequestDTO>)Session["ItemDetails"]; RequestDTO newItem = addItem.FirstOrDefault(x => x.ItemCode == lblItemCode.Text); if (newItem == null) { if (!String.IsNullOrEmpty(tbxQuantity.Text)) { newItem = new RequestDTO(lblItemCode.Text, lblCategory.Text, lblDescription.Text, Convert.ToInt32(tbxQuantity.Text)); addItem.Add(newItem); Session["ItemDetails"] = addItem; } else if (rdlQuantity.SelectedItem.Selected) { newItem = new RequestDTO(lblItemCode.Text, lblCategory.Text, lblCategory.Text, Convert.ToInt32(rdlQuantity.SelectedItem.Text)); addItem.Add(newItem); Session["ItemDetails"] = addItem; } } else { if (!String.IsNullOrEmpty(tbxQuantity.Text)) { newItem.Quantity += Convert.ToInt32(tbxQuantity.Text); addItem.RemoveAll(x => x.ItemCode == lblItemCode.Text); addItem.Add(newItem); Session["ItemDetails"] = addItem; } else if (rdlQuantity.SelectedItem.Selected) { newItem.Quantity += Convert.ToInt32(rdlQuantity.SelectedItem.Text); addItem.RemoveAll(x => x.ItemCode == lblItemCode.Text); addItem.Add(newItem); Session["ItemDetails"] = addItem; } } } if (IsRedirect() && Session["ItemDetails"] != null) { Response.Redirect("RequisitionDetails.aspx?REQUESTCODE=" + requestcode); } else { //show success message System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(@"<script type='text/javascript'>"); sb.Append("$('#myModal').modal('show');"); sb.Append(@"</script>"); ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none", sb.ToString(), false); } } }
public int InsertRow(RequestDetail RequestDetail) { DbTransaction Tran = null; return(InsertRow(Tran, RequestDetail)); }
public int DeleteRow(RequestDetail RequestDetail) { DbTransaction Tran = null; return(DeleteRow(Tran, RequestDetail)); }
private IRequestDetail GetRequestDetail(HttpContext context, IRequestInfo request) { IRequestDetail model = new RequestDetail(); if (context.Request != null) { model.Id = MD5_16(Guid.NewGuid().ToString()); model.RequestId = request.Id; Dictionary <string, string> cookies = context.Request.Cookies.ToList().ToDictionary(x => x.Key, x => x.Value); if (cookies != null && cookies.Count > 0) { model.Cookie = JsonConvert.SerializeObject(cookies); } Dictionary <string, string> headers = context.Request.Headers.ToList().ToDictionary(x => x.Key, x => x.Value.ToString()); if (headers != null && headers.Count > 0) { model.Header = JsonConvert.SerializeObject(headers); } if (context.Items.ContainsKey(BasicConfig.HttpReportsGlobalException)) { Exception ex = context.Items[BasicConfig.HttpReportsGlobalException] as Exception; if (ex != null) { model.ErrorMessage = ex.Message; model.ErrorStack = ex.StackTrace; } context.Items.Remove(BasicConfig.HttpReportsGlobalException); } if (context.Items.ContainsKey(BasicConfig.HttpReportsRequestBody)) { string requestBody = context.Items[BasicConfig.HttpReportsRequestBody] as string; if (requestBody != null) { model.RequestBody = requestBody; } context.Items.Remove(BasicConfig.HttpReportsRequestBody); } if (context.Items.ContainsKey(BasicConfig.HttpReportsResponseBody)) { string responseBody = context.Items[BasicConfig.HttpReportsResponseBody] as string; if (responseBody != null) { model.ResponseBody = responseBody; } context.Items.Remove(BasicConfig.HttpReportsResponseBody); } model.CreateTime = DateTime.Now; model.Scheme = context.Request.Scheme; model.QueryString = context.Request.QueryString.Value; } return(model); }
public static bool MapRequestAsInput(RequestDTO requestDTO) { bool result = default(bool); _Request = new Request(); _RequestDetailListInput = new List <RequestDetail>(); RequestDetail _RequestDetailTemp = default(RequestDetail); try { if (requestDTO != null) { // Request Data Part _Request.Id = requestDTO.Id; _Request.requestNumber = requestDTO.requestNumber; _Request.totalQuantity = requestDTO.totalQuantity; _Request.PDD = Formatter.formatStringtoDate(requestDTO.PDD); // DateTime.ParseExact(requestDTO.PDD, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (requestDTO.customerID != null) { _Request.customerID = requestDTO.customerID.Id; } _Request.creationDate = Formatter.formatStringtoDate(requestDTO.creationDate); // DateTime.ParseExact(requestDTO.creationDate, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (requestDTO.creationUserID != null) { _Request.creationUserID = requestDTO.creationUserID.Id; } _Request.approvalDate = Formatter.formatStringtoDate(requestDTO.approvalDate); //DateTime.ParseExact(requestDTO.approvalDate, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (requestDTO.approvalUserID != null) { _Request.approvalUserID = requestDTO.approvalUserID.Id; } _Request.receiveDate = Formatter.formatStringtoDate(requestDTO.receiveDate); //DateTime.ParseExact(requestDTO.receiveDate, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (requestDTO.receiveUserID != null) { _Request.receiveUserID = requestDTO.receiveUserID.Id; } _Request.rejectionDate = Formatter.formatStringtoDate(requestDTO.rejectionDate); //DateTime.ParseExact(requestDTO.rejectionDate, "yyyy-MM-dd", CultureInfo.InvariantCulture); if (requestDTO.rejectionUserID != null) { _Request.rejectionUserID = requestDTO.rejectionUserID.Id; } if (requestDTO.rejectionReasonID != null) { _Request.rejectionReasonID = requestDTO.rejectionReasonID.Id; } if (requestDTO.requestTypeID != null) { _Request.requestTypeID = requestDTO.requestTypeID.Id; } if (requestDTO.requestStatusID != null) { _Request.requestStatusID = requestDTO.requestStatusID.Id; } if (requestDTO.requestCalssID != null) { _Request.requestCalssID = requestDTO.requestCalssID.Id; } if (requestDTO.requestPriorityID != null) { _Request.requestPriorityID = requestDTO.requestPriorityID.Id; } // Request Details Data Part if (requestDTO.RequestDetailList != null && requestDTO.RequestDetailList.Count > 0) { foreach (RequestDetailDTO _RequestDetailDTO in requestDTO.RequestDetailList) { _RequestDetailTemp = new RequestDetail(); _RequestDetailTemp.Id = _RequestDetailDTO.Id; _RequestDetailTemp.quantity = _RequestDetailDTO.quantity; _RequestDetailTemp.requestID = requestDTO.Id; if (_RequestDetailDTO.cardTypeDTO != null) { _RequestDetailTemp.cardTypeID = _RequestDetailDTO.cardTypeDTO.Id; } _RequestDetailListInput.Add(_RequestDetailTemp); } } result = true; } } catch (Exception) { throw; } return(result); }
public RequestBag(RequestInfo info, RequestDetail detail) { this.RequestInfo = info; this.RequestDetail = detail; }
/// <summary> /// Return ManufacturerModel Entity /// </summary> public async Task <ManufacturerModel> GetManufacturerModelByNameAsync(string name, Manufacturer manufacturer, RequestDetail requestDetail) { var entity = await _contextDb.ManufacturerModels.FirstOrDefaultAsync(_ => _.Name == name.Trim() && _.Manufacturer.Id == manufacturer.Id); if (entity != null) { return(entity); } entity = new ManufacturerModel { Id = 0, Name = name, Manufacturer = manufacturer }; await _contextDb.ManufacturerModels.AddAsync(entity); if (requestDetail.ManufacturerModel != null) { var hasOnceManufacturerInRequest = await _contextDb.RequestDetails.CountAsync(_ => _.ManufacturerModel.Id == requestDetail.ManufacturerModel.Id) > 1; if (hasOnceManufacturerInRequest) { _contextDb.ManufacturerModels.Remove(requestDetail.ManufacturerModel); requestDetail.ManufacturerModel = null; } } return(entity); }
public override ErrorList Validate() { var result = new ErrorList(); result.AddRange(base.Validate()); if (StatusElement != null) { result.AddRange(StatusElement.Validate()); } if (IssuedElement != null) { result.AddRange(IssuedElement.Validate()); } if (Subject != null) { result.AddRange(Subject.Validate()); } if (Performer != null) { result.AddRange(Performer.Validate()); } if (ReportId != null) { result.AddRange(ReportId.Validate()); } if (RequestDetail != null) { RequestDetail.ForEach(elem => result.AddRange(elem.Validate())); } if (ServiceCategory != null) { result.AddRange(ServiceCategory.Validate()); } if (DiagnosticTimeElement != null) { result.AddRange(DiagnosticTimeElement.Validate()); } if (Results != null) { result.AddRange(Results.Validate()); } if (Image != null) { Image.ForEach(elem => result.AddRange(elem.Validate())); } if (ConclusionElement != null) { result.AddRange(ConclusionElement.Validate()); } if (CodedDiagnosis != null) { CodedDiagnosis.ForEach(elem => result.AddRange(elem.Validate())); } if (Representation != null) { Representation.ForEach(elem => result.AddRange(elem.Validate())); } return(result); }