protected void btnSave_Click(object sender, EventArgs e) { try { /* * if (txtProductName.Text == "") * { * txtProductName.Focus(); * return; * } */ // PDTO.ProductName = txtProductName.Text.ToString(); PDTO.ProductPurchasePrice = Convert.ToDouble(txtPurchasePrice.Text); PDTO.CategoryId = Convert.ToInt16(ddlCategory.SelectedValue); // PDTO.UnitId = Convert.ToInt16(ddlUnit.SelectedValue); PDTO.CompId = Convert.ToInt16(ddlCompany.SelectedValue); PDTO.CenterReorderValue = Convert.ToInt32(txtCenterReorderQuantity.Text); PDTO.CreateDate = System.DateTime.Now; PDTO.ProductSalePrice = Convert.ToDouble(txtSalePrice.Text); PDTO.ProductOffSalePrice = Convert.ToDouble(txtOffSale.Text); PDTO.CreateBy = HttpContext.Current.User.Identity.Name; PDTO.ProductReOrderStatus = 0; if (btnSave.Text == "Save") { var checkCount = PBLL.CheckProductCodeExits(int.Parse(ddlCompany.SelectedValue), "", int.Parse(ddlCategory.SelectedValue)); if (checkCount.Count() > 0) { Show("Product already Exist in this company "); return; } else { PBLL.Add(PDTO); Show("Sucessfully Created!"); pagingLoal(); clearCntrol(); // barcode /* * var data = PBLL.GetProduct(0, "", 0, 0, 0); * string productid = data.First().ProductId.ToString(); * txtProductBarCode.Text = productid; * if (txtProductBarCode.Text != "") * ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "key", "launchModal();", true); * */ } } else { PDTO.ProductId = Convert.ToInt32(HFUID.Value); //var checkUpCount = PBLL.CheckProductCodeExits(int.Parse(ddlCompany.SelectedValue), txtProductName.Text,int.Parse(HFUID.Value)); //if (checkUpCount.Count()> 0) //{ // Show("Product Code :" + txtProductName.Text + " already Used By Another Product in this company "); // return; //}else{ PBLL.Edit(PDTO); btnSave.Text = "Save"; Show("Sucessfully Updated!"); pagingLoal(); clearCntrol(); // barcode // for barcode popup /* * string Empid = Convert.ToString(HFUID.Value); * txtProductBarCode.Text = Empid; * if (txtProductBarCode.Text != "") * ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "key", "launchModal();", true); * */ //} } } catch (Exception ex) { Show(ex.Message); } }