private InventoryControlModel SetValues() { if (gvInventoryDetail.Rows.Count <= 0) { Messages1.SetMessage("You must add atleast one inventory details to save the approval!", Messages.MessageType.Error); return(null); } InventoryControlModel icm = new InventoryControlModel(); InventoryDetail invdetail; string status = ""; foreach (GridViewRow gr in gvInventoryDetail.Rows) { status = ((RadioButtonList)gr.FindControl("chkApproval")).SelectedValue; invdetail = new InventoryDetail(); if (status == "Approve") { invdetail.Status = (int)InventoryDetailStatus.Approved; } else if (status == "Reject") { invdetail.Status = (int)InventoryDetailStatus.Rejected; } else { continue; } invdetail.ID = new Guid(((Label)gr.FindControl("lblID")).Text); invdetail.InventoryID = new Guid(((Label)gr.FindControl("lblInventoryID")).Text); invdetail.StackID = new Guid(((Label)gr.FindControl("lblStackID")).Text); invdetail.LastModifiedBy = UserBLL.CurrentUser.UserId; invdetail.LastModifiedTimestamp = DateTime.Now; invdetail.ApprovalDate = DateTime.Now; invdetail.ApprovedByID = UserBLL.CurrentUser.UserId; icm.addInventoryDetail(invdetail); } if (icm.inventoryDetailList != null && icm.inventoryDetailList.Count > 0) { icm.ID = icm.inventoryDetailList[0].InventoryID; } return(icm); }
private InventoryControlModel SetValues() { InventoryControlModel icm = new InventoryControlModel(); icm.ID = Guid.NewGuid(); icm.LICID = new Guid(drpLIC.SelectedValue); icm.InventoryReasonID = int.Parse(drpInventoryReason.SelectedValue); icm.WarehouseID = UserBLL.GetCurrentWarehouse(); icm.ShedID = new Guid(drpShed.SelectedValue); icm.CreatedBy = UserBLL.CurrentUser.UserId; icm.CreateTimestamp = DateTime.Now; icm.InventoryDate = DateTime.Parse(txtInventoryControlDate.Text); icm.PSAStackID = Guid.Empty; //if (InventoryControlModel.InventoryControlExits(icm)) //{ // Messages1.SetMessage("Inventory Control exits! You can't insert inventory control for the same Shed, Lead Inventory Controller and Inventory Date!", Messages.MessageType.Error); // return null; //} if (ViewState["psaApprovalInfoXML"] != null) { icm.psaApprovalInfoXML = ViewState["psaApprovalInfoXML"].ToString(); string psaID = icm.psaApprovalInfoXML.Substring( icm.psaApprovalInfoXML.IndexOf("<ID>") + 4, 36); icm.PSAID = new Guid(psaID); ViewState["psaApprovalInfoXML"] = null; } InventoryDetail invdetail; float count = -1; float weight = -1; bool stackSelected = false; foreach (GridViewRow gr in gvInventoryDetail.Rows) { if (((CheckBox)gr.FindControl("rdoPSAstack")).Checked) { stackSelected = true; TextBox pc = ((TextBox)gr.FindControl("txtPhysicalCount")); TextBox pw = ((TextBox)gr.FindControl("txtPhysicalWeight")); if (pc.Text.Trim() == string.Empty && pw.Text.Trim() == string.Empty) { continue; } invdetail = new InventoryDetail(); invdetail.InventoryID = icm.ID; invdetail.StackID = new Guid(((Label)gr.FindControl("lblId")).Text); icm.PSAStackID = invdetail.StackID; //b coz PSA occurres in only one stack. if (float.TryParse(((Label)gr.FindControl("lblSystemCount")).Text, out count) && count >= 0) { invdetail.SystemCount = count; count = -1; } else { invdetail.SystemCount = 0; } if (float.TryParse(((Label)gr.FindControl("lblSystemWeight")).Text, out weight) && weight >= 0) { invdetail.SystemWeight = weight; weight = -1; } else { invdetail.SystemWeight = 0; } if (float.TryParse(pc.Text, out count) && count >= 0) { invdetail.PhysicalCount = (float)Math.Round(count, 2); count = -1; } else { Messages1.SetMessage("Physical count entry invalid for selected Stack number " + ((Label)gr.FindControl("lblStackNo")).Text + "!.Please insert non-negative integer", Messages.MessageType.Error); return(null); } if (float.TryParse(pw.Text, out weight) && weight >= 0) { invdetail.PhysicalWeight = (float)Math.Round(weight); weight = -1; } else { Messages1.SetMessage("Physical weight entry invalid for selected Stack number " + ((Label)gr.FindControl("lblStackNo")).Text + "!.Please insert non-negative decimal number.", Messages.MessageType.Error); return(null); } invdetail.AdjustmentCount = invdetail.PhysicalCount - invdetail.SystemCount; invdetail.AdjustmentWeight = invdetail.PhysicalWeight - invdetail.SystemWeight; invdetail.CreatedBy = icm.CreatedBy; invdetail.CreateTimestamp = icm.CreateTimestamp; if (icm.PSAID != null && !icm.PSAID.ToString().Equals(Guid.Empty.ToString())) { invdetail.ApprovalDate = DateTime.Now; invdetail.ApprovedByID = UserBLL.CurrentUser.UserId; invdetail.Status = (int)InventoryDetailStatus.Approved; } icm.addInventoryDetail(invdetail); break; // b coz PSA occers in only one stack. } } if (!stackSelected) { Messages1.SetMessage("Please Identifay the stack that PSA Occurred! ", Messages.MessageType.Error); return(null); } if (icm.inventoryDetailList == null || icm.inventoryDetailList.Count <= 0) { Messages1.SetMessage("Physical count and weight required for at least one Stack ", Messages.MessageType.Error); return(null); } InventoryInspector invins; foreach (GridViewRow gr1 in gvInventoryInspectors.Rows) { invins = new InventoryInspector(); invins.InventoryID = icm.ID; invins.InspectorID = new Guid(((Label)gr1.FindControl("lblInspectorID")).Text); invins.InspectorName = ((Label)gr1.FindControl("lblInspectorName")).Text; if (((TextBox)gr1.FindControl("txtPosition")).Text.Trim() != string.Empty) { invins.Position = ((TextBox)gr1.FindControl("txtPosition")).Text; } else { Messages1.SetMessage("Please enter position for the Inspector " + invins.InspectorName + "!", Messages.MessageType.Error); return(null); } icm.addInventoryInspector(invins); } return(icm); }