Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                // need to change now for new fcked up logic

                if (Session["MODE"].Equals("ADD"))
                {
                    btnCreateProduct.Text = "ADD";

                    #region Populating BarCode Serial
                    try
                    {
                        connection.Open();
                        SqlCommand     command = new SqlCommand("Select Count(*) From tbl_ProductMaster Where Product_Id_Org LIKE '2%';", connection);
                        DataSet        ds      = new DataSet();
                        SqlDataAdapter sA      = new SqlDataAdapter(command);
                        sA.Fill(ds);

                        if (ds.Tables[0].Rows[0][0].ToString().Length.Equals(7))
                        {
                            BarCodeSerial.Text = "2" + (Int32.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
                        }
                        else if (ds.Tables[0].Rows[0][0].ToString().Length.Equals(6))
                        {
                            BarCodeSerial.Text = "20" + (Int32.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
                        }
                        else if (ds.Tables[0].Rows[0][0].ToString().Length.Equals(5))
                        {
                            BarCodeSerial.Text = "200" + (Int32.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
                        }
                        else if (ds.Tables[0].Rows[0][0].ToString().Length.Equals(4))
                        {
                            BarCodeSerial.Text = "2000" + (Int32.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
                        }
                        else if (ds.Tables[0].Rows[0][0].ToString().Length.Equals(3))
                        {
                            BarCodeSerial.Text = "20000" + (Int32.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
                        }

                        else if (ds.Tables[0].Rows[0][0].ToString().Length.Equals(2))
                        {
                            BarCodeSerial.Text = "200000" + (Int32.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
                        }

                        else if (ds.Tables[0].Rows[0][0].ToString().Length.Equals(1))
                        {
                            BarCodeSerial.Text = "2000000" + (Int32.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
                        }
                        else if (ds.Tables[0].Rows[0][0].ToString().Length < 1)
                        {
                            BarCodeSerial.Text = "2000000" + (Int32.Parse(ds.Tables[0].Rows[0][0].ToString()) + 1).ToString();
                        }
                    }
                    catch (Exception ex)
                    {
                    }
                    finally
                    {
                        connection.Close();
                    }
                    #endregion

                    BarCodeSerial.Visible = true;
                }
                else if (Session["MODE"].Equals("EDIT"))
                {
                    btnCreateProduct.Text    = "UPDATE";
                    BarCodeSerial.Visible    = false;
                    lblBarcodeSerial.Visible = false;
                }

                #region Master Search Mechanism
                if (Session["PageMasterProduct"] != null && Session["PageMasterProduct"].ToString() != null &&
                    Session["PageMasterProduct"].ToString() != "" && Session["PageMasterProduct"].ToString() != "false")
                {
                    FromMaster_Load(Session["MS_ItemNo"].ToString(), Session["MS_ItemName"].ToString(), Session["MS_ItemType"].ToString(), Session["MS_Manufacterer"].ToString(),
                                    Session["MS_Category"].ToString(), Session["MS_GenericName"].ToString(), Session["MS_Control"].ToString(), Session["MS_BinNumber"].ToString(),
                                    Session["MS_GreenRainCode"].ToString(), Session["MS_BrandName"].ToString(), Session["MS_MaxiMumDiscount"].ToString(), Session["MS_LineID"].ToString(),
                                    Session["MS_UnitSale"].ToString(), Session["MS_UnitCost"].ToString(), Session["MS_itemAWT"].ToString(), Session["MS_itemForm"].ToString(),
                                    Session["MS_itemStrength"].ToString(), Session["MS_itemPackType"].ToString(), Session["MS_itemPackSize"].ToString(), Session["MS_Description"].ToString());
                }
                #endregion


                #region Populating Product Type DropDown
                ProductType.Items.Add("Medicine(HAAD)");
                ProductType.Items.Add("Medicine(Non HAAD)");
                ProductType.Items.Add("NonMedicine");

                if (Session["MODE"].Equals("EDIT"))
                {
                    foreach (ListItem Items  in ProductType.Items)
                    {
                        if (Items.Text.Equals(Session["MS_ItemType"].ToString()))
                        {
                            ProductType.SelectedIndex = ProductType.Items.IndexOf(Items);
                            break;
                        }
                    }
                    //int selIndex;
                    //int.TryParse(Session["MS_ProductOrderType"].ToString(), out selIndex);
                    //ddlProductOrderType.SelectedIndex = selIndex;
                    // foreach( )
                }
                #endregion

                #region Populating Product Department DropDown
                try
                {
                    connection.Open();
                    SqlCommand     command = new SqlCommand("Select * From tblDepartment", connection);
                    DataSet        ds      = new DataSet();
                    SqlDataAdapter sA      = new SqlDataAdapter(command);
                    sA.Fill(ds);
                    ProductDept.DataSource     = ds.Tables[0];
                    ProductDept.DataTextField  = "Name";
                    ProductDept.DataValueField = "DepId";
                    ProductDept.DataBind();
                    if (ProductDept != null)
                    {
                        ProductDept.Items.Insert(0, "Select Department");
                        ProductDept.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    connection.Close();
                }
                #endregion

                #region Populate Product Order Type

                ddlProductOrderType.DataSource     = IMSGlobal.GetOrdersType();
                ddlProductOrderType.DataTextField  = "Name";
                ddlProductOrderType.DataValueField = "OrderTypeId";
                ddlProductOrderType.DataBind();

                if (ddlProductOrderType != null)
                {
                    ddlProductOrderType.Items.Insert(0, "Select Product Order Type");
                    ddlProductOrderType.SelectedIndex = 0;
                }

                if (Session["MODE"].Equals("EDIT"))
                {
                    int selIndex;
                    int.TryParse(Session["MS_ProductOrderType"].ToString(), out selIndex);
                    ddlProductOrderType.SelectedIndex = selIndex;
                    // foreach( )
                }
                #endregion
            }
        }
Ejemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                #region Populating Product Type DropDown
                ProductType.Items.Add("Select Product Type");
                ProductType.Items.Add("Medicine(HAAD)");
                ProductType.Items.Add("Medicine(Non HAAD)");
                ProductType.Items.Add("Non Medicine");
                #endregion

                #region Populating Product Department DropDown
                try
                {
                    connection.Open();
                    SqlCommand     command = new SqlCommand("Select * From tblDepartment", connection);
                    DataSet        ds      = new DataSet();
                    SqlDataAdapter sA      = new SqlDataAdapter(command);
                    sA.Fill(ds);
                    ProductDept.DataSource     = ds.Tables[0];
                    ProductDept.DataTextField  = "Name";
                    ProductDept.DataValueField = "DepId";
                    ProductDept.DataBind();
                    if (ProductDept != null)
                    {
                        ProductDept.Items.Insert(0, "Select Department");
                        ProductDept.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    connection.Close();
                }
                #endregion

                #region Populating Category Dropdown
                try
                {
                    connection.Open();
                    SqlCommand     command = new SqlCommand("Select * From tblCategory", connection);
                    DataSet        ds      = new DataSet();
                    SqlDataAdapter sA      = new SqlDataAdapter(command);
                    sA.Fill(ds);
                    ProductCat.DataSource     = ds.Tables[0];
                    ProductCat.DataTextField  = "Name";
                    ProductCat.DataValueField = "CategoryID";
                    ProductCat.DataBind();
                    if (ProductCat != null)
                    {
                        ProductCat.Items.Insert(0, "Select Category");
                        ProductCat.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    connection.Close();
                }
                #endregion

                #region Populating SubCategory Dropdown
                try
                {
                    connection.Open();
                    SqlCommand     command = new SqlCommand("Select * From tblSub_Category", connection);
                    DataSet        ds      = new DataSet();
                    SqlDataAdapter sA      = new SqlDataAdapter(command);
                    sA.Fill(ds);
                    ProductSubCat.DataSource     = ds.Tables[0];
                    ProductSubCat.DataTextField  = "Name";
                    ProductSubCat.DataValueField = "Sub_CatID";
                    ProductSubCat.DataBind();

                    if (ProductSubCat != null)
                    {
                        ProductSubCat.Items.Insert(0, "Select Sub Category");
                        ProductSubCat.SelectedIndex = 0;
                    }
                }
                catch (Exception ex)
                {
                }
                finally
                {
                    connection.Close();
                }
                #endregion

                #region ProductOrderType dropdown population
                ddlProductOrderType.DataSource     = IMSGlobal.GetOrdersType();
                ddlProductOrderType.DataTextField  = "Name";
                ddlProductOrderType.DataValueField = "OrderTypeId";
                ddlProductOrderType.DataBind();

                if (ddlProductOrderType != null)
                {
                    ddlProductOrderType.Items.Insert(0, "Select Product Order Type");
                    ddlProductOrderType.SelectedIndex = 0;
                }
                #endregion

                BindGridbyFilters();
            }
        }