Пример #1
0
        protected void GridViewProduct_AddProd(object sender, EventArgs e)
        {
            Product prd = new Product();

            String price = ((TextBox)GridViewProduct.FooterRow.FindControl("txt_prd_price")).Text;

            if (String.IsNullOrEmpty(price) || String.IsNullOrWhiteSpace(price))
            {
                return;
            }

            prd.prd_name = ((TextBox)GridViewProduct.FooterRow.FindControl("txt_prd_name")).Text;
            try
            {
                prd.prd_price = Decimal.Parse(price);
            }
            catch (Exception ex)
            {
                prd.prd_price = (Decimal)0.00;
            }

            prd.prd_sup_no = ((TextBox)GridViewProduct.FooterRow.FindControl("txt_prd_sup_no")).Text;
            prd.prd_memo   = ((TextBox)GridViewProduct.FooterRow.FindControl("txt_prd_memo")).Text;

            if (String.IsNullOrEmpty(prd.prd_name) || String.IsNullOrWhiteSpace(prd.prd_name))
            {
                return;
            }


            foreach (Product prod in SupplierBll.LoadAllProduct())
            {
                if (prod.prd_sup_no.Equals(prd.prd_sup_no))
                {
                    return;
                }
            }

            Supplier sup = (Supplier)Session["supplier"];

            prd.sup_id = sup.sup_id;

            try
            {
                SupplierBll.InsertProduct(prd);

                GridViewProduct.PageIndex = GridViewProduct.PageCount;

                BindDataProduct();
            }
            catch (ManagedException ex)
            {
                Utils.DisplayMessage(UpdatePanelSupplier, String.Format("alert(\"{0}\");", ex.Message));
            }
        }