//Add New Supplier private void AddSupplier() { tblSupplier supplier = repo.Get_SupplierbyCode(txtcode.Text.Trim()); if (supplier != null) { ClientScript.RegisterStartupScript(this.GetType(), "toastr", "toastr.error('Same code already exist,please try again');", true); } else { if (db.tblSuppliers.FirstOrDefault(x => x.Name == txtName.Text.Trim() && x.IsDeleted == false) != null) { if (Session["WarningShow"] == null) { Session["WarningShow"] = "1"; ClientScript.RegisterStartupScript(this.GetType(), "toastr", "toastr.warning('Same name already exist. Click on save again to save record.');", true); } } if (Session["WarningShow"] == "1") { Session["WarningShow"] = "2"; } else { tblSupplier tblSupplier = new tblSupplier(); tblSupplier.Code = txtcode.Text.ToString(); tblSupplier.Name = txtName.Text.ToString(); tblSupplier.Address1 = txtaddress1.Text.ToString(); tblSupplier.Address2 = txtaddress2.Text.ToString(); tblSupplier.City = txtcity.Text.ToString(); tblSupplier.State = txtstate.Text.ToString(); tblSupplier.Country = txtcountry.Text.ToString(); tblSupplier.GSTNo = txtgstno.Text.ToString(); tblSupplier.PanNo = txtpanno.Text.ToString(); tblSupplier.ContactPerson = txtperson.Text.ToString(); tblSupplier.ContactMobile = txtmobile.Text.ToString(); tblSupplier.ContactEMail = txtemail.Text.ToString(); tblSupplier.IsDeleted = false; if (repo.Add_Supplier(tblSupplier)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "toastr", "toastr.success('Supplier Record Saved Successfully')", true); HtmlMeta meta = new HtmlMeta(); meta.HttpEquiv = "Refresh"; meta.Content = "1;url=AddEdit.aspx"; this.Page.Controls.Add(meta); } } } }