protected void GetProductRequisitionProductListById(string productRequisitionId)
        {
            ProductRequisitionBLL productRequisition = new ProductRequisitionBLL();

            try
            {
                //Need to solve
                DataTable dt = productRequisition.GetProductRequisitionProductListById(productRequisitionId,"");

                if (dt.Rows.Count > 0)
                {
                    productRequisitionProductListGridView.DataSource = dt;
                    productRequisitionProductListGridView.DataBind();

                    if (productRequisitionProductListGridView.Rows.Count > 0)
                    {
                        productRequisitionProductListGridView.UseAccessibleHeader = true;
                        productRequisitionProductListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                    }
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                productRequisition = null;
            }
        }
        protected void GetProductRequisitionById(string productRequisitionId)
        {
            ProductRequisitionBLL productRequisition = new ProductRequisitionBLL();

            try
            {
                DataTable dt = productRequisition.GetProductRequisitionById(productRequisitionId);

                if (dt.Rows.Count > 0)
                {
                    requisitionDateLabel.Text = dt.Rows[0]["RequisitionDate"].ToString();
                    //salesCenterIdLabel.Text = dt.Rows[0]["SalesCenterId"].ToString();
                    //salesCenterNameLabel.Text = dt.Rows[0]["SalesCenterName"].ToString();
                    warehouseIdLabel.Text = dt.Rows[0]["WarehouseId"].ToString();
                    warehouseNameLabel.Text = dt.Rows[0]["WarehouseName"].ToString();
                    narrationLabel.Text = dt.Rows[0]["Narration"].ToString();
                    statusLabel.Text = dt.Rows[0]["Status"].ToString();
                    lblCreatedBy.Text = dt.Rows[0]["CreatedUser"].ToString();
                    reqTypelabel.Text = dt.Rows[0]["RequisitionType"].ToString();
                    //CreatedUser
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                productRequisition = null;
            }
        }
        protected void GetProductRequisitionById(string productRequisitionId)
        {
            ProductRequisitionBLL productRequisition = new ProductRequisitionBLL();
            //spanreqsc.Attributes.Remove("class");
            spanreqwh.Attributes.Remove("class");

            try
            {
                DataTable dt = productRequisition.GetProductRequisitionById(productRequisitionId);

                if (dt.Rows.Count > 0)
                {
                    requisitionDateLabel.Text = dt.Rows[0]["RequisitionDate"].ToString();
                    //salesCenterIdLabel.Text = dt.Rows[0]["SalesCenterId"].ToString();
                    //salesCenterNameLabel.Text = dt.Rows[0]["SalesCenterName"].ToString();
                    warehouseIdLabel.Text = dt.Rows[0]["WarehouseId"].ToString();
                    warehouseNameLabel.Text = dt.Rows[0]["WarehouseName"].ToString();
                    narrationLabel.Text = dt.Rows[0]["Narration"].ToString();
                    statusLabel.Text = dt.Rows[0]["Status"].ToString();
                    lblCreatedBy.Text = dt.Rows[0]["CreatedUser"].ToString();
                    reqTypelabel.Text = dt.Rows[0]["RequisitionType"].ToString();
                    //        if (reqTypelabel.Text == "WH-SC")
                    //        {

                    //            spanreqwh.Attributes.Add("class", "text-error icon icon-upload");
                    //            spanreqsc.Attributes.Add("class", "text-success icon icon-download-alt");
                    //        }
                    //        else if (reqTypelabel.Text == "SC-WH")
                    //        {
                    //            spanreqsc.Attributes.Add("class", "text-error icon icon-upload");
                    //            spanreqwh.Attributes.Add("class", "text-success icon icon-download-alt");
                    //        }
                    //    }
                    //    else
                    //    {
                    //        msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                    //    }
                    //}
                }
            }
            catch
                (Exception ex)
            {
                msgbox.Visible = true;
                msgTitleLabel.Text = "Exception!!!";
                msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                productRequisition = null;
            }
        }
        protected void GetProductRequisitionProductListById(string productRequisitionId, string reqType)
        {
            ProductRequisitionBLL productRequisition = new ProductRequisitionBLL();

            try
            {
                DataTable dt = productRequisition.GetProductRequisitionProductListById(productRequisitionId, reqType);

                if (dt.Rows.Count > 0)
                {
                    productRequisitionProductListGridView.DataSource = dt;
                    productRequisitionProductListGridView.DataBind();

                    if (productRequisitionProductListGridView.Rows.Count > 0)
                    {
                        approveButton.Enabled = true;
                        productRequisitionProductListGridView.UseAccessibleHeader = true;
                        productRequisitionProductListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;

                        TextBox approveQuantityTextBox;

                        for (int i = 0; i < productRequisitionProductListGridView.Rows.Count; i++)
                        {
                            approveQuantityTextBox = (TextBox)productRequisitionProductListGridView.Rows[i].FindControl("approveQuantityTextBox");
                            //approveQuantityTextBox.Text = productRequisitionProductListGridView.Rows[i].Cells[3].Text.ToString();
                            approveQuantityTextBox.Text = dt.Rows[i][3].ToString();
                        }
                    }
                    else
                    {
                        approveButton.Enabled = false;
                    }
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                productRequisition = null;
            }
        }
        protected void approveButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (productRequisitionProductListGridView.Rows.Count > 0)
                {
                    TextBox approveQuantityTextBox;
                    decimal num; bool isApproveQuantityNum;
                    DropDownList statusDropDownList;
                    TextBox narrationTextBox;
                    string freeQtyWas;

                    DataTable dt = new DataTable();
                    DataRow dr = null;
                    dt.Columns.Add(new DataColumn("ProductId"));
                    dt.Columns.Add(new DataColumn("ApprovedQuantity"));
                    dt.Columns.Add(new DataColumn("Status"));
                    dt.Columns.Add(new DataColumn("Narration"));
                    dt.Columns.Add(new DataColumn("FreeQuantityWas"));

                    for (int i = 0; i < productRequisitionProductListGridView.Rows.Count; i++)
                    {
                        approveQuantityTextBox = (TextBox)productRequisitionProductListGridView.Rows[i].FindControl("approveQuantityTextBox");
                        isApproveQuantityNum = decimal.TryParse(approveQuantityTextBox.Text.Trim(), out num);
                        statusDropDownList = (DropDownList)productRequisitionProductListGridView.Rows[i].FindControl("statusDropDownList");
                        narrationTextBox = (TextBox)productRequisitionProductListGridView.Rows[i].FindControl("narrationTextBox");
                        freeQtyWas = productRequisitionProductListGridView.Rows[i].Cells[4].Text.Trim();

                        if (statusDropDownList.SelectedValue == "")
                        {
                            msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Product ID [" + productRequisitionProductListGridView.Rows[i].Cells[0].Text.ToString() + "] has no status selected.";
                            return;
                        }

                        dr = dt.NewRow();
                        dr["ProductId"] = productRequisitionProductListGridView.Rows[i].Cells[0].Text.ToString();
                        dr["ApprovedQuantity"] = num.ToString();//approveQuantityTextBox.Text.Trim();
                        dr["Status"] = statusDropDownList.SelectedValue.Trim();
                        dr["Narration"] = narrationTextBox.Text.Trim();
                        dr["FreeQuantityWas"] = freeQtyWas.Trim();
                        dt.Rows.Add(dr);
                    }

                    if (dt.Rows.Count == productRequisitionProductListGridView.Rows.Count)
                    {
                        ProductRequisitionBLL productRequisition = new ProductRequisitionBLL();

                        string productRequisitionId = idLabel.Text.Trim();
                        string transferFrom = "";
                        string transferTo = "";
                        string transferType = "";
                        //if (reqTypelabel.Text == "WH-SC")
                        //{


                        //    transferFrom = warehouseIdLabel.Text.Trim();
                        //    transferTo = salesCenterIdLabel.Text.Trim();

                        //}
                        //else if (reqTypelabel.Text == "SC-WH")
                        //{
                        //    transferTo = warehouseIdLabel.Text.Trim();
                        //    transferFrom = salesCenterIdLabel.Text.Trim();
                        //}
                        //string transferType = reqTypelabel.Text;

                        string msg = productRequisition.ApproveTransferRequisitionAndCreateTransferOrder(dt, productRequisitionId, transferFrom, transferTo, transferType);

                        MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/ProductRequisition/ApprovalRequisitionList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + msg + "\", callbackOk);");
                        //MyAlertBox("alert(\"" + msg + " \"); window.location=\"/UI/ProductRequisition/ApprovalRequisitionList.aspx\"");
                    }
                    else
                    {
                        msgbox.Visible = true; msgTitleLabel.Text = "Collected Data Count Mismatch!!!"; msgDetailLabel.Text = "";
                    }
                }
            }
            catch (Exception ex)
            {
                // msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
        }
        protected void GetProductRequisitionsApprovalListByWarehouse(string salesCenterId)
        {
            ProductRequisitionBLL productRequisition = new ProductRequisitionBLL();

            try
            {
                DataTable dt = productRequisition.GetProductRequisitionsApprovalListBySalesCenter(salesCenterId,"");

                productRequisitionApprovalListGridView.DataSource = dt;
                productRequisitionApprovalListGridView.DataBind();

                if (productRequisitionApprovalListGridView.Rows.Count > 0)
                {
                    productRequisitionApprovalListGridView.UseAccessibleHeader = true;
                    productRequisitionApprovalListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                }
                else
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                productRequisition = null;
            }
        }
Ejemplo n.º 7
0
        protected void requisitionListButton_Click(object sender, EventArgs e)
        {
            ProductRequisitionBLL productRequisition = new ProductRequisitionBLL();

            try
            {
                //if (salesCenterDropDownList.SelectedValue == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Sales Center Name field is required.";
                //}
                if (fromDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim()) == "False")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date From field is required.";
                }
                else if (toDateTextBox.Text.Trim() == "" || LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim()) == "False")
                {
                    msgbox.Visible = true; msgTitleLabel.Text = "Validation!!!"; msgDetailLabel.Text = "Date To field is required.";
                }
                else
                {
                    string salesCenterId = WarehouesDropDownList.SelectedValue.Trim();
                    string fromDate = LumexLibraryManager.ParseAppDate(fromDateTextBox.Text.Trim());
                    string toDate = LumexLibraryManager.ParseAppDate(toDateTextBox.Text.Trim());
                    string status = statusDropDownList.SelectedValue.Trim();
                    string ReqType = "";

                    DataTable dt = new DataTable();

                    dt = productRequisition.GetProductRequisitionsListBySalesCenterDateRangeAndStatus(salesCenterId, fromDate, toDate, status, ReqType);

                    productRequisitionListGridView.DataSource = dt;
                    productRequisitionListGridView.DataBind();

                    if (productRequisitionListGridView.Rows.Count > 0)
                    {
                        productRequisitionListGridView.UseAccessibleHeader = true;
                        productRequisitionListGridView.HeaderRow.TableSection = TableRowSection.TableHeader;
                    }
                    else
                    {
                        msgbox.Visible = true; msgTitleLabel.Text = "Data Not Found!!!"; msgDetailLabel.Text = "";
                    }
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                productRequisition = null;
                MyAlertBox("MyOverlayStop();");
            }
        }
        protected void saveButton_Click(object sender, EventArgs e)
        {
            string msg = string.Empty;

            List<ProductRequisitionBLL> productRequisitions = new List<ProductRequisitionBLL>();
            ProductRequisitionBLL productRequisition;
            decimal quantity = 0;
            TextBox requisitionQuantityTextBox;
            TextBox requiredDateTextBox;
            TextBox productNarrationTextBox;
            int i = 0;

            try
            {
                //if (salesCenterDropDownList.SelectedValue == "")
                //{
                //    msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = "Sales Center Name field is required.";
                //}
                //else
                //{
                    for (i = 0; i < selectedProductListGridView.Rows.Count; i++)
                    {
                        requisitionQuantityTextBox = (TextBox)selectedProductListGridView.Rows[i].Cells[4].FindControl("requisitionQuantityTextBox");
                        requiredDateTextBox = (TextBox)selectedProductListGridView.Rows[i].Cells[5].FindControl("requiredDateTextBox");
                        productNarrationTextBox = (TextBox)selectedProductListGridView.Rows[i].Cells[6].FindControl("productNarrationTextBox");

                        if (!string.IsNullOrEmpty(requisitionQuantityTextBox.Text.Trim()) && decimal.TryParse(requisitionQuantityTextBox.Text.Trim(), out quantity))
                        {
                            quantity = decimal.Parse(requisitionQuantityTextBox.Text.Trim());

                            productRequisition = new ProductRequisitionBLL();

                            productRequisition.ProductId = selectedProductListGridView.Rows[i].Cells[1].Text.ToString();
                            productRequisition.RequisitionQuantity = quantity.ToString();
                            productRequisition.RequiredDate = LumexLibraryManager.ParseAppDate(requiredDateTextBox.Text.ToString());
                            productRequisition.ProductNarration = productNarrationTextBox.Text.ToString();
                            productRequisitions.Add(productRequisition);
                        }
                        else
                        {
                            msg = "Product ID [" + selectedProductListGridView.Rows[i].Cells[1].Text.ToString() + "] has no valid quantity.";
                            msgbox.Visible = true; msgTitleLabel.Text = "Warning!!!"; msgDetailLabel.Text = msg;
                            return;
                        }
                    

                    if (productRequisitions.Count > 0)
                    {
                        productRequisition = new ProductRequisitionBLL();

                        string productRequisitionId = productRequisition.SaveProductRequisition(productRequisitions, "", WarehouesDropDownList.SelectedValue.Trim(), "", narrationTextBox.Text.Trim());

                        string message = "Product Requisition <span class='actionTopic'>Created</span> Successfully Product Requisition ID: <span class='actionTopic'>" + productRequisitionId + "</span>.";
                        MyAlertBox("var callbackOk = function () { MyOverlayStart(); window.location = \"/UI/ProductRequisition/RequisitionList.aspx\"; }; SuccessAlert(\"" + "Process Succeed" + "\", \"" + message + "\", callbackOk);");

                        //MyAlertBox("alert(\"Product Requisition Created Successfully with Product Requisition ID: " + productRequisitionId + " \"); window.location=\"/UI/ProductRequisition/RequisitionList.aspx\"");
                    }
                }
            }
            catch (Exception ex)
            {
                msgbox.Visible = true; msgTitleLabel.Text = "Exception!!!"; msgDetailLabel.Text = ex.Message;
            }
            finally
            {
                productRequisition = null;
                productRequisitions = null;
            }
        }