Example #1
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                //shabda
                if (BtnSave.Text == "Update")
                {
                    if (ddlProduct.SelectedValue == "")
                    {
                        Hashtable ht = new Hashtable();
                        ht.Add("ReqNo", txtRequisitionNo.Text);
                        ht.Add("ReqType", "Purchase");
                        ht.Add("CompanyCode", "");
                        ht.Add("DPT_CODE", ddlDepartment.SelectedValue);
                        ht.Add("EID", ddlEmployee.SelectedValue);
                        ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode);
                        ht.Add("RecomendBy", "n/a");
                        ht.Add("Reason_Justification", txtJustification.Text);
                        ht.Add("ReqDate", txtDate.Text);
                        ht.Add("DesiredRcvDate", txtExpectedDate.Text);
                        ht.Add("Remarks", txtRemarks.Text);

                        if (RequisionBll.updatepurchaseRequisition(ht) == false)
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition updated successfully')", true);
                            ShowRequisitionDataForGrid();
                            ClearForm();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition updating error!')", true);
                            //lblMessage.Text = "<font color='red'>Error in updating requisition! Please try again</font>";
                        }
                    }
                    else if (Convert.ToInt32(ddlProduct.SelectedValue) == 0)
                    {
                        Hashtable ht = new Hashtable();
                        ht.Add("ReqNo", txtRequisitionNo.Text);
                        ht.Add("ReqType", "Purchase");
                        ht.Add("CompanyCode", "");
                        ht.Add("DPT_CODE", ddlDepartment.SelectedValue);
                        ht.Add("EID", ddlEmployee.SelectedValue);
                        ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode);
                        ht.Add("RecomendBy", "n/a");
                        ht.Add("Reason_Justification", txtJustification.Text);
                        ht.Add("ReqDate", txtDate.Text);
                        ht.Add("DesiredRcvDate", txtExpectedDate.Text);
                        ht.Add("Remarks", txtRemarks.Text);

                        if (RequisionBll.updatepurchaseRequisition(ht) == false)
                        {
                            ClearForm();
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition updated successfully')", true);
                            ShowRequisitionDataForGrid();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition updating error!')", true);
                            //lblMessage.Text = "<font color='red'>Error in updating requisition! Please try again</font>";
                        }
                    }
                    else if (Convert.ToInt32(ddlProductGroup.SelectedValue) != 0 && Convert.ToInt32(ddlProduct.SelectedValue) != 0)
                    {
                        DataTable dt      = new DataTable();
                        string    ReqNo   = txtRequisitionNo.Text;
                        string    Barocde = ddlProduct.SelectedValue;
                        dt = RequisionBll.GetBarCode(ReqNo, Barocde);
                        if (dt.Rows.Count > 0)
                        {
                            Hashtable ht = new Hashtable();
                            ht.Add("ReqNo", txtRequisitionNo.Text);
                            ht.Add("ReqType", "Purchase");
                            ht.Add("CompanyCode", "");
                            ht.Add("DPT_CODE", ddlDepartment.SelectedValue);
                            ht.Add("EID", ddlEmployee.SelectedValue);
                            ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode);
                            ht.Add("RecomendBy", "n/a");
                            ht.Add("Reason_Justification", txtJustification.Text);
                            ht.Add("ReqDate", txtDate.Text);
                            ht.Add("DesiredRcvDate", txtExpectedDate.Text);
                            ht.Add("Remarks", txtRemarks.Text);

                            ht.Add("Qty", txtQuantity.Text);
                            ht.Add("BarCode", ddlProduct.SelectedValue);

                            if (RequisionBll.updatePurchaseRequisitions(ht) == false)
                            {
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition updated successfully')", true);
                                ShowRequisitionDataForGrid();
                                ClearForm();
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition updating error!')", true);
                                //lblMessage.Text = "<font color='red'>Error in updating requisition! Please try again</font>";
                            }
                        }
                        else
                        {
                            Hashtable ht = new Hashtable();
                            ht.Add("ReqNo", txtRequisitionNo.Text);
                            ht.Add("ReqType", "Purchase");
                            ht.Add("CompanyCode", "");
                            ht.Add("DPT_CODE", ddlDepartment.SelectedValue);
                            ht.Add("EID", ddlEmployee.SelectedValue);
                            ht.Add("BarCode", ddlProduct.SelectedValue);
                            ht.Add("Qty", txtQuantity.Text);
                            ht.Add("ReqDate", txtDate.Text);
                            ht.Add("DesiredRcvDate", txtExpectedDate.Text);
                            ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode);
                            ht.Add("RecomendBy", "n/a");
                            ht.Add("Reason_Justification", txtJustification.Text);
                            ht.Add("Remarks", txtRemarks.Text);
                            if (RequisionBll.AddPurchaseRequisition(ht))
                            {
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition updated successfully')", true);
                                LoadRequisitions(txtRequisitionNo.Text);
                                ClearForm();
                            }
                            else
                            {
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition updating error!')", true);
                                //lblMessage.Text = "<font color='red'>Error in updating requisition! Please try again</font>";
                            }
                        }
                    }
                }
            }
            catch { }
        }
Example #2
0
        protected void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                BindRequisitionNo();
                string BarCode  = ddlProduct.SelectedValue;
                string Quantity = txtQuantity.Text;
                string ReqDate  = txtDate.Text;

                if (BarCode == "" || Quantity == "" || ReqDate == "" || ddlDepartment.SelectedValue == "0" || ddlEmployee.SelectedValue == "0" || txtRequisitionNo.Text == "")
                {
                    return;
                }

                if (int.Parse(txtQuantity.Text) <= 0)
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition quantity cannot be zero or negative!')", true);
                    //lblMessage.Text = "<font color='red'>Sorry! Invalid data. Requisition quantity cannot be zero or negative. Please enter correct data</font>";
                    return;
                }

                Inv_Product product = productBll.GetAllItem(int.Parse(ddlProduct.SelectedValue), txtDescription.Text);
                if (BtnSave.Text == "Add")
                {
                    if (product == null)
                    {
                        Inv_Product productObj = new Inv_Product();

                        string   pronductNameandBrand = ddlProduct.SelectedItem.ToString();
                        string[] values = pronductNameandBrand.Split('-');
                        productObj.ProductName = values[0].ToString();

                        productObj.StyleAndSize = txtDescription.Text;
                        productObj.ReOrderQty   = 0;
                        productObj.Brand        = "HB";
                        productObj.GroupId      = Convert.ToInt32(ddlProductGroup.SelectedValue);
                        productObj.GroupName    = ddlProductGroup.SelectedItem.Text;
                        productObj.UnitId       = int.Parse(ddlUnit.SelectedValue);
                        productObj.UnitName     = ddlUnit.SelectedItem.Text;
                        productObj.ProductType  = "Consumable Product";
                        productObj.EditDate     = DateTime.Now;
                        //productObj.EditUser = Guid.Parse("a376708d-757f-4777-bd05-bfc89b6971ce");
                        productObj.EditUser = ((SessionUser)Session["SessionUser"]).UserId;
                        productObj.OCode    = ((SessionUser)Session["SessionUser"]).OCode.ToString();
                        //productObj.OCode = "8989";

                        productBll.InsertProduct(productObj);

                        //PRQ_Requisitions requisition = new PRQ_Requisitions();
                        //requisition.ReqNo = txtRequisitionNo.Text;
                        //requisition.ReqType = "Purchase";
                        ////requisition.CompanyCode = "";
                        //requisition.DPT_CODE = ddlDepartment.SelectedValue;
                        //requisition.EID = ddlEmployee.SelectedValue;
                        //requisition.Qty = int.Parse(txtQuantity.Text);
                        //requisition.ReqDate = DateTime.Parse(txtDate.Text);
                        //requisition.DesiredRcvDate = DateTime.Parse(txtExpectedDate.Text);
                        //requisition.OCode = ((SessionUser)Session["SessionUser"]).OCode;
                        //requisition.RecomendBy = txtRecommendedBy.Text;
                        //requisition.Reason_Justification = txtJustification.Text;
                        //requisition.Remarks = txtRemarks.Text;

                        //aRequisionBll.AddPurchaseRequisition_ForNewItem(values[0].ToString(), txtDescription.Text);

                        Hashtable ht = new Hashtable();
                        ht.Add("ReqNo", txtRequisitionNo.Text);
                        ht.Add("ReqType", "Purchase");
                        ht.Add("CompanyCode", "");
                        ht.Add("DPT_CODE", ddlDepartment.SelectedValue);
                        ht.Add("EID", ddlEmployee.SelectedValue);
                        //ht.Add("BarCode", ddlProduct.SelectedValue);
                        ht.Add("Qty", txtQuantity.Text);
                        ht.Add("ReqDate", txtDate.Text);
                        ht.Add("DesiredRcvDate", txtExpectedDate.Text);
                        ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode);
                        ht.Add("RecomendBy", "n/a");
                        ht.Add("Reason_Justification", txtJustification.Text);
                        ht.Add("Remarks", txtRemarks.Text);

                        if (RequisionBll.AddPurchaseRequisition_ForNewItem(ht, values[0].ToString(), txtDescription.Text))
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition for this item added successfully')", true);
                            //lblMessage.Text = "<font color='green'>Requisition for this item added successfully!</font>";
                            LoadRequisitions(txtRequisitionNo.Text);
                            ClearForm();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Error in adding requisition!')", true);
                            //lblMessage.Text = "<font color='red'>Error in adding requisition! Please try again</font>";
                        }
                    }
                    else
                    {
                        Hashtable ht = new Hashtable();
                        ht.Add("ReqNo", txtRequisitionNo.Text);
                        ht.Add("ReqType", "Purchase");
                        ht.Add("CompanyCode", "");
                        ht.Add("DPT_CODE", ddlDepartment.SelectedValue);
                        ht.Add("EID", ddlEmployee.SelectedValue);
                        ht.Add("BarCode", ddlProduct.SelectedValue);
                        ht.Add("Qty", txtQuantity.Text);
                        ht.Add("ReqDate", txtDate.Text);
                        ht.Add("DesiredRcvDate", txtExpectedDate.Text);
                        ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode);
                        ht.Add("RecomendBy", "n/a");
                        ht.Add("Reason_Justification", txtJustification.Text);
                        ht.Add("Remarks", txtRemarks.Text);

                        if (RequisionBll.AddPurchaseRequisition(ht))
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition for this item added successfully')", true);
                            //lblMessage.Text = "<font color='green'>Requisition for this item added successfully!</font>";
                            LoadRequisitions(txtRequisitionNo.Text);
                            ClearForm();
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Error in adding requisition!')", true);
                            //lblMessage.Text = "<font color='red'>Error in adding requisition! Please try again</font>";
                        }
                    }
                }

                else if (BtnSave.Text == "Update")
                {
                    DataTable dt      = new DataTable();
                    string    ReqNo   = txtRequisitionNo.Text;
                    string    Barocde = ddlProduct.SelectedValue;
                    dt = RequisionBll.GetBarCode(ReqNo, Barocde);
                    if (dt.Rows.Count > 0)
                    {
                        Hashtable ht = new Hashtable();
                        ht.Add("ReqNo", txtRequisitionNo.Text);
                        ht.Add("ReqType", "Purchase");
                        ht.Add("CompanyCode", "");
                        ht.Add("DPT_CODE", ddlDepartment.SelectedValue);
                        ht.Add("EID", ddlEmployee.SelectedValue);
                        ht.Add("OCode", ((SessionUser)Session["SessionUser"]).OCode);
                        ht.Add("RecomendBy", "n/a");
                        ht.Add("Reason_Justification", txtJustification.Text);
                        ht.Add("ReqDate", txtDate.Text);
                        ht.Add("DesiredRcvDate", txtExpectedDate.Text);
                        ht.Add("Remarks", txtRemarks.Text);
                        ht.Add("Qty", txtQuantity.Text);
                        ht.Add("BarCode", ddlProduct.SelectedValue);

                        if (RequisionBll.updatePurchaseRequisitions(ht) == false)
                        {
                            ClearForm();
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Requisition for this item updated successfully')", true);
                            LoadRequisitions(txtRequisitionNo.Text);
                            BtnSave.Text = "Add";
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Error in adding requisition!')", true);
                            //lblMessage.Text = "<font color='red'>Error in adding requisition! Please try again</font>";
                        }
                    }
                }
            }

            catch { }
        }