//Save University #region SaveData protected void btnSave_Click(object sender, EventArgs e) { objEWA = new EWA_Trailset(); try { lock (this) { objEWA = new EWA_Trailset(); objEWA.Action = "CheckData"; int rs = objBL.CheckOrganization_BL(objEWA); if (rs == 1) { msgBox.ShowMessage("Record Already Exist!!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); clear(); // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Designation Already Exists')", true); } else { Action("Save"); clear(); } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//To CheckOrganization #region [Check Organization] public int CheckOrganization_DL(EWA_Trailset objEWA) { try { cmd = new SqlCommand("SP_Trailset", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Action", objEWA.Action); cmd.Parameters.AddWithValue("@OrgId", objEWA.OrgId); con.Open(); int flag = cmd.ExecuteNonQuery(); con.Close(); return(flag); } catch (Exception ex) { int err = ((System.Data.SqlClient.SqlException)(ex)).Number; if (err == 547 && objEWA.Action == "Delete") { throw new SystemException("Record is in use !!!"); } else { throw ex; } } finally { con.Close(); cmd.Dispose(); } }
//Perform Action for University #region [Perform Action] private void Action(string strAction) { try { objEWA = new EWA_Trailset(); objEWA.Action = strAction; objEWA.id = "0"; if (strAction == "Update" || strAction == "Delete") { objEWA.id = ViewState["id"].ToString(); } objEWA.ValidDate = txtValidDate.Text.Trim(); objEWA.SenderId = txtSenderId.Text.Trim(); objEWA.AppKey = txtAppKey.Text.ToString(); objEWA.OrgId = DDL_Organization.SelectedValue.ToString(); int flag = objBL.TrailsetAction_BL(objEWA); if (flag > 0) { if (strAction == "Save") { msgBox.ShowMessage("Record Saved Successfully !!!", "Saved", UserControls.MessageBox.MessageStyle.Successfull); } else if (strAction == "Update") { msgBox.ShowMessage("Record Updated Successfully !!!", "Updated", UserControls.MessageBox.MessageStyle.Successfull); //Page.Response.Redirect(HttpContext.Current.Request.Url.ToString(), true); } else if (strAction == "Delete") { msgBox.ShowMessage("Record Deleted Successfully !!!", "Deleted", UserControls.MessageBox.MessageStyle.Successfull); } GrdOrganizationBind(); } else { if (strAction == "Save") { msgBox.ShowMessage("Unable to Save !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } else if (strAction == "Update") { msgBox.ShowMessage("Unable to Update !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } else if (strAction == "Delete") { msgBox.ShowMessage("Unable to Delete !!!", "Critical", UserControls.MessageBox.MessageStyle.Critical); } } } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//To Bind Grd #region [Bind Grd] public int TrailsetAction_BL(EWA_Trailset objEWA) { try { DL_Trailset objDL = new DL_Trailset(); int ds = objDL.TrailsetAction_DL(objEWA); return(ds); } catch (Exception) { throw; } }
//To CheckOrganization #region [Check Organization] public int CheckOrganization_BL(EWA_Trailset objEWA) { try { DL_Trailset objDL = new DL_Trailset(); int ds = objDL.CheckOrganization_DL(objEWA); return(ds); } catch (Exception) { throw; } }
//To Call Country Grid Bind #region [Country Grid Bind] public DataSet Bind_DDLOrganization_BL(EWA_Trailset objEWA) { try { DL_Trailset objDL = new DL_Trailset(); DataSet ds = objDL.Bind_DDLOrganization_DL(objEWA); return(ds); } catch (Exception) { throw; } }
//Organization Bind #region [Organization Bind] public void Bind_DDLOrganization() { objEWA = new EWA_Trailset(); objEWA.Action = "FatchOrganization"; DataSet ds = objBL.Bind_DDLOrganization_BL(objEWA); DDL_Organization.DataSource = ds; DDL_Organization.DataTextField = "OrgName"; DDL_Organization.DataValueField = "OrganizationId"; DDL_Organization.DataBind(); DDL_Organization.Items.Insert(0, "Select"); DDL_Organization.SelectedIndex = 0; }
//Trailset Grid Bind #region [Trailset Grid Bind] private void GrdOrganizationBind() { try { objEWA = new EWA_Trailset(); objEWA.Action = "SelectData"; DataSet ds = objBL.Bind_DDLOrganization_BL(objEWA); GrdTrailset.DataSource = ds; GrdTrailset.DataBind(); } catch (Exception exp) { GeneralErr(exp.Message.ToString()); } }
//To Bind Organization #region [Bind Organization] public DataSet Bind_DDLOrganization_DL(EWA_Trailset objEWA) { DataSet ds = new DataSet(); try { prmList = new string[2]; prmList[0] = "@Action"; prmList[1] = objEWA.Action; ds = ObjHelper.FillControl(prmList, "SP_Trailset"); if (ds.Tables[0].Rows.Count > 0) { return(ds); } return(ds); } catch (Exception exp) { throw exp; } }