Exemplo n.º 1
0
        protected void BtnSendReq_Click(object sender, EventArgs e)
        {
            statusMessage.Visible = false;
            InventoryLogic il         = new InventoryLogic();
            string         clerkName  = HttpContext.Current.Profile.GetPropertyValue("fullname").ToString();
            int            avRId      = InventoryLogic.CreateAdjustmentVoucherRequest(clerkName, DateTime.Now.Date);
            bool           isAbove250 = false;

            try
            {
                foreach (GridViewRow r in GridViewAdjV.Rows)
                {
                    string itemID    = (r.FindControl("TxtItemCode") as TextBox).Text;
                    string itemName  = (r.FindControl("LblDesc") as Label).Text;
                    string type      = (r.FindControl("DdlAdjType") as DropDownList).SelectedValue;
                    int    quantity  = int.Parse((r.FindControl("TxtAdjQty") as TextBox).Text);
                    string uom       = (r.FindControl("LblUOM") as Label).Text;
                    string reason    = (r.FindControl("TxtReason") as TextBox).Text;
                    double unitPrice = InventoryLogic.GetInventoryPrice(itemID);

                    if (!InventoryLogic.IsUnitsInStock(itemID, quantity) && type == "Minus")
                    {
                        statusMessage.Text      = "Error! Insufficient stock for adjustment. " + itemName;
                        statusMessage.ForeColor = Color.Red;
                        statusMessage.Visible   = true;
                        return;
                    }

                    InventoryLogic.CreateAdjustmentVoucherRequestDetails(avRId, itemID, type, quantity, uom, reason, unitPrice);
                    isAbove250 = (quantity * unitPrice > 250 ? true : false);
                    InventoryLogic.SendAdjRequentEmail(avRId, isAbove250, clerkName);
                }
            }catch (Exception ex)
            {
                statusMessage.Text      = "Error! Invalid Submission Request.";
                statusMessage.ForeColor = Color.Red;
                statusMessage.Visible   = true;
                Console.WriteLine(ex.ToString());
                return;
            }

            string successMsg = "Request Sent. Inventory Adjustment Voucher Request ID: " + avRId.ToString() + " has been created";

            Session["AdjustVID"]   = avRId;
            Session["AdjVSuccess"] = successMsg;
            Response.Redirect("~/StoreClerk/ViewAdjustmentVoucherDetails.aspx");
            BtnSendReq.Enabled = true;
        }
Exemplo n.º 2
0
        public string CreateAdjustmentRequest(WCF_AVRequestDetail avrDetail, string token)
        {
            string result = "Faliure";

            //Check if user is authorizated to use this method. If is not authorized, it will return a json with -1 in the primary key
            if (!IsAuthanticateUser(token))
            {
                result = "Invalid User";
                return(result);
            }

            string fullName = GetUserFullName(token);

            try
            {
                int AVRID = InventoryLogic.CreateAdjustmentVoucherRequest(fullName, DateTime.Now.Date);
                if (!InventoryLogic.IsUnitsInStock(avrDetail.ItemID, avrDetail.Quantity) && avrDetail.Type == "Minus")
                {
                    return(result);
                }

                double unitPrice = InventoryLogic.GetInventoryPrice(avrDetail.ItemID);

                InventoryLogic.CreateAdjustmentVoucherRequestDetails
                    (AVRID, avrDetail.ItemID, avrDetail.Type, avrDetail.Quantity, avrDetail.UOM, avrDetail.Reason, unitPrice);

                bool isAbove250 = (avrDetail.Quantity * unitPrice > 250 ? true : false);
                InventoryLogic.SendAdjRequentEmail(AVRID, isAbove250, fullName);
                result = "Success";
                return(result);
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
        }