Example #1
0
        protected void btnAddInventroyinspector_Click(object sender, EventArgs e)
        {
            Messages1.ClearMessage();
            if (drpInventoryInspector.SelectedIndex <= 0)
            {
                Messages1.SetMessage("Inventory Adjustment was succesfully saved!", Messages.MessageType.Success);
                upMessage.Update();
                return;
            }

            InventoryInspector invIns = new InventoryInspector();

            invIns.InspectorID = new Guid(drpInventoryInspector.SelectedValue);
            Guid insID = invIns.InspectorID;

            invIns.InspectorName = drpInventoryInspector.SelectedItem.Text;
            List <InventoryInspector> invInsectors = inventoryInspectors;

            if (invInsectors.Exists(iins => iins.InspectorID.Equals(insID)))
            {
                Messages1.SetMessage("The inspector is already added to the list!", Messages.MessageType.Warning);
                upMessage.Update();
                return;
            }
            invInsectors.Add(invIns);
            ViewState.Add("InventoryInspectors", invInsectors);
            gvInventoryInspectors.DataSource = inventoryInspectors;
            gvInventoryInspectors.DataBind();
            drpInventoryInspector.ClearSelection();
            upMessage.Update();
        }
Example #2
0
        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);
        }