protected void btnsave_Click(object sender, EventArgs e) { try { EventLogger log = new EventLogger(config); string FacilityVendorAcct = string.Empty; string lstrMessage = string.Empty; InventoryServiceClient service = new InventoryServiceClient(); BALFacilityVendorAccount obj = new BALFacilityVendorAccount(); obj.FacilityVendorAccID = Convert.ToInt64(hdnFVAccountID.Value); obj.FacilityID = Convert.ToInt64(drdFacilityName.SelectedValue); obj.VendorID = Convert.ToInt64(drdVendorName.SelectedValue); obj.ShipAccount = txtShipAccount.Text; obj.BillAccount = txtBillAccount.Text; obj.CreatedBy = defaultPage.UserId; obj.CreatedOn = DateTime.Now; if (chkactive.Checked == true) { obj.IsActive = true; } else { obj.IsActive = false; } if (obj.FacilityVendorAccID == 0) { List <GetFacilityVendorAccount> lstcount = service.GetFacilityVendorAccount(drdFacilityName.SelectedItem.Text).Where(o => o.VendorDescription == drdVendorName.SelectedItem.Text.ToString()).ToList(); if (lstcount.Count <= 0) { lstrMessage = service.InsertUpdateFacilityVendorAccount(obj); FacilityVendorAcct = drdFacilityName.SelectedItem.Text + " " + drdVendorName.SelectedItem.Text; log.LogInformation(msgwrn.Replace("<<FacilityDescription>>", FacilityVendorAcct.ToString())); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.FacilityVendorAccountSaveMessage.Replace("<<FacilityDescription>>", FacilityVendorAcct.ToString()), true); } else { //Functions objfun = new Functions(); //objfun.MessageDialog(this, "Record Exist"); string msg = Constant.WarningFacilityVendorAccountMessage.Replace("ShowwarningLookupPopup('", "").Replace("<<FacilityDescription>>", "Record Exists").Replace("');", ""); log.LogWarning(msg); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.WarningFacilityVendorAccountMessage.Replace("<<FacilityDescription>>", "Record Exists"), true); } } else { if (!ValidateLoookups(service)) { return; } List <GetFacilityVendorAccount> lstcount = service.GetFacilityVendorAccount(drdFacilityName.SelectedItem.Text).Where(o => o.VendorDescription == drdVendorName.SelectedItem.Text.ToString() && o.FacilityVendorAccID != obj.FacilityVendorAccID).ToList(); if (lstcount.Count == 0) { lstrMessage = service.InsertUpdateFacilityVendorAccount(obj); FacilityVendorAcct = drdFacilityName.SelectedItem.Text + " " + drdVendorName.SelectedItem.Text; log.LogInformation(msgwrn.Replace("<<FacilityDescription>>", FacilityVendorAcct.ToString())); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.FacilityVendorAccountSaveMessage.Replace("<<FacilityDescription>>", FacilityVendorAcct.ToString()), true); } else { //Functions objfun = new Functions(); //objfun.MessageDialog(this, "The Record Entered is alredy Exist"); string msg = Constant.FacilityVendorAccountErrorMessage.Replace("ShowdelPopup('", "").Replace("<<FacilityDescription>>", "The record entered is already exist").Replace("');", ""); log.LogWarning(msg); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.FacilityVendorAccountErrorMessage.Replace("<<FacilityDescription>>", "The record entered is already exist"), true); } } if (lstrMessage == "Saved Successfully") { //Functions objfun = new Functions(); //objfun.MessageDialog(this, "Saved Successfully"); //txtSearchFacility.Text = ""; BindGrid(); drdFacilityName.SelectedIndex = 0; drdVendorName.SelectedIndex = 0; txtBillAccount.Text = ""; txtShipAccount.Text = ""; hdnFVAccountID.Value = "0"; ToggleAdd("Clear"); } } catch (Exception ex) { EventLogger log = new EventLogger(config); log.LogException(ex); ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", Constant.FacilityVendorAccountErrorMessage.Replace("<<FacilityDescription>>", ex.Message), true); } }