Example #1
0
    protected void btnQuickAddProduct_Click(object sender, EventArgs e)
    {
        if (txtCompanyName.Text != string.Empty && txtCategory.Text != string.Empty && txtFlavor.Text != string.Empty)
        {
            lblError.Visible = true;
            Product p = new Product();

            p.Category    = txtCategory.Text.Trim();
            p.CompanyName = txtCompanyName.Text.Trim();
            p.Flavor      = txtFlavor.Text.Trim();
            if (chkCF.Checked)
            {
                p.CF = true;
            }
            else
            {
                p.CF = false;
            }
            if (chkSF.Checked)
            {
                p.SF = true;
            }
            else
            {
                p.SF = false;
            }
            if (chkCT.Checked)
            {
                p.CRT = true;
            }
            else
            {
                p.CRT = false;
            }
            if (chkFC.Checked)
            {
                p.FAC = true;
            }
            else
            {
                p.FAC = false;
            }
            p.LastUpdated = DateTime.Now;
            p.Type1       = txtType1.Text;
            p.Type2       = txtType2.Text;
            p.User        = ((Users)Session["User"]).UserName;

            ProductWorker w = new ProductWorker();

            bool result = w.AddProduct(p);
            if (result)
            {
                MessageBox("Product Added!");
            }
            else
            {
                MessageBox("Product Add Error!");
            }

            Session.Remove("Products");

            ClearQuickAddProduct();
        }
        else
        {
            MessageBox("Category, Company or Flavor cannot be empty");
            //lblError.Text = "Category, Company or Flavor cannot be empty";
            //lblError.Visible = true;
        }
    }