using System; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; public partial class frmViewCareerRegistrationDetails : System.Web.UI.Page { SqlConnection sqlConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["RSIC"].ConnectionString); SqlDataAdapter sda = null; DataSet ds = null; protected void Page_Load(object sender, EventArgs e) { } string QueryCondition() { string strQuery = ""; string[] type = new string[18]; string[] toArray = new string[18]; string datefor; string dateto; string dateform; string datetostr; if ((txtDateFrom.Value != "") && (txtDateTo.Value == "")) { datefor = txtDateFrom.Value; type = datefor.Split('-'); if (strQuery == "") { strQuery = " And RecordEntryTime ='" + type[1] + "-" + type[0] + "-" + type[2] + "'"; } else { strQuery = strQuery + " And RecordEntryTime ='" + type[1] + "-" + type[0] + "-" + type[2] + "'"; } } if ((txtDateFrom.Value != "") && (txtDateTo.Value != "")) { datefor = txtDateFrom.Value; dateto = txtDateTo.Value; type = datefor.Split('-'); dateform = type[1] + "-" + type[0] + "-" + type[2]; toArray = dateto.Split('-'); datetostr = toArray[1] + "-" + toArray[0] + "-" + toArray[2]; if (strQuery == "") { strQuery = " And RecordEntryTime between Convert(nvarchar(50),Convert(DAtetime,'" + dateform + "'),101) and Convert(nvarchar(50),Convert(DAtetime,'" + datetostr + "'),101)"; } else { strQuery = strQuery + " And RecordEntryTime between Convert(nvarchar(50),Convert(DAtetime,'" + dateform + "'),101) and Convert(nvarchar(50),Convert(DAtetime,'" + datetostr + "'),101)"; } } return strQuery; } protected void gvPnlCareerDetails_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ((LinkButton)(e.Row.FindControl("LinkButton1"))).Attributes.Add("OnClick", "javascript:CallPrintPage('" + e.Row.Cells[0].Text + "');"); } } protected void btnViewAluminiDetails_Click(object sender, EventArgs e) { try { sqlConn.Open(); string condition = Convert.ToString(QueryCondition()); string strQuery = "Select EmploymentCareerApplicationMain.EmpID, EmploymentCareerApplicationMain.EmpName, EmploymentCareerApplicationMain.ResidentialNo, EmploymentCareerApplicationMain.EmailID, EmploymentCareerApplicationMain.TotlExpinYear, EmploymentCareerApplicationMain.JoiningDate, CAST(ExpInternatonalScholYer AS Varchar(10)) + ' Yrs ' + CAST(ExpInternatonalScholMont AS varchar(10)) + ' Mnths ' AS IntExp, CAST(ExpIndianScholYer AS Varchar(10)) + ' Yrs ' + CAST(ExpIndianScholMonth AS varchar(10)) AS IndExp, EmploymentCareerApplicationData.PositionAppliedFor From EmploymentCareerApplicationMain INNER JOIN EmploymentCareerApplicationData ON EmploymentCareerApplicationMain.EmpId = EmploymentCareerApplicationData.EmpId Where 1=1 " + condition + ""; sda = new SqlDataAdapter(strQuery, sqlConn); ds = new DataSet(); sda.Fill(ds,"table"); if (ds.Tables["table"].Rows.Count > 0) { pnlViewCareerDetails.Visible = true; gvPnlCareerDetails.DataSource = ds.Tables["table"]; gvPnlCareerDetails.DataBind(); } else { Response.Write(""); pnlViewCareerDetails.Visible = false; gvPnlCareerDetails.DataSource = null; gvPnlCareerDetails.DataBind(); } } catch (Exception ex) { Response.Write(""); pnlViewCareerDetails.Visible = false; gvPnlCareerDetails.DataSource = null; gvPnlCareerDetails.DataBind(); } finally { sqlConn.Close(); } } protected void gvPnlCareerDetails_PageIndexChanging(object sender, GridViewPageEventArgs e) { gvPnlCareerDetails.PageIndex = e.NewPageIndex; sqlConn.Open(); string condition = Convert.ToString(QueryCondition()); string strQuery = " Select EmploymentCareerApplicationMain.EmpID, EmploymentCareerApplicationMain.EmpName, EmploymentCareerApplicationMain.ResidentialNo, EmploymentCareerApplicationMain.EmailID, EmploymentCareerApplicationMain.TotlExpinYear, EmploymentCareerApplicationMain.JoiningDate, CAST(ExpInternatonalScholYer AS Varchar(10)) + ' Yrs ' + CAST(ExpInternatonalScholMont AS varchar(10)) + ' Mnths ' AS IntExp, CAST(ExpIndianScholYer AS Varchar(10)) + ' Yrs ' + CAST(ExpIndianScholMonth AS varchar(10)) AS IndExp, EmploymentCareerApplicationData.PositionAppliedFor From EmploymentCareerApplicationMain INNER JOIN EmploymentCareerApplicationData ON EmploymentCareerApplicationMain.EmpId = EmploymentCareerApplicationData.EmpId Where 1=1 " + condition + ""; sda = new SqlDataAdapter(strQuery, sqlConn); ds = new DataSet(); sda.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { pnlViewCareerDetails.Visible = true; gvPnlCareerDetails.DataSource = ds.Tables[0]; gvPnlCareerDetails.DataBind(); } else { Response.Write(""); pnlViewCareerDetails.Visible = false; gvPnlCareerDetails.DataSource = null; gvPnlCareerDetails.DataBind(); } } protected void gvPnlCareerDetails_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.Pager) { DropDownList ddl = new DropDownList(); //adds variants of pager size ddl.Items.Add("10"); ddl.Items.Add("25"); ddl.Items.Add("50"); ddl.Items.Add("100"); ddl.Items.Add("150"); ddl.AutoPostBack = true; //selects item due to the GridView current page size ListItem li = ddl.Items.FindByText(gvPnlCareerDetails.PageSize.ToString()); if (li != null) ddl.SelectedIndex = ddl.Items.IndexOf(li); ddl.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); //adds dropdownlist in the additional cell to the pager table Table pagerTable = e.Row.Cells[0].Controls[0] as Table; TableCell cell = new TableCell(); cell.Style["padding-left"] = "15px"; cell.Controls.Add(new LiteralControl("Page Size:")); cell.Controls.Add(ddl); pagerTable.Rows[0].Cells.Add(cell); } } void ddl_SelectedIndexChanged(object sender, EventArgs e) { //changes page size gvPnlCareerDetails.PageSize = int.Parse(((DropDownList)sender).SelectedValue); sqlConn.Open(); string strQuery = "Select EmploymentCareerApplicationMain.EmpID, EmploymentCareerApplicationMain.EmpName, EmploymentCareerApplicationMain.ResidentialNo, EmploymentCareerApplicationMain.EmailID, EmploymentCareerApplicationMain.TotlExpinYear, EmploymentCareerApplicationMain.JoiningDate, CAST(ExpInternatonalScholYer AS Varchar(10)) + ' Yrs ' + CAST(ExpInternatonalScholMont AS varchar(10)) + ' Mnths ' AS IntExp, CAST(ExpIndianScholYer AS Varchar(10)) + ' Yrs ' + CAST(ExpIndianScholMonth AS varchar(10)) AS IndExp, EmploymentCareerApplicationData.PositionAppliedFor From EmploymentCareerApplicationMain INNER JOIN EmploymentCareerApplicationData ON EmploymentCareerApplicationMain.EmpId = EmploymentCareerApplicationData.EmpId "; sda = new SqlDataAdapter(strQuery, sqlConn); ds = new DataSet(); sda.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { gvPnlCareerDetails.DataSource = ds.Tables[0]; gvPnlCareerDetails.DataBind(); } } protected void gvPnlCareerDetails_SelectedIndexChanged(object sender, EventArgs e) { } }