public void fillgrid() { if (ddlUser.SelectedValue == "All Users") { pnlgrid.Visible = true; BA_Timesheet batime = new BA_Timesheet(); DataSet ds = new DataSet(); string StartDt = txtStartDate.Text; string EndDt = txtEndDate.Text; ds = batime.GetCompanyReports(id, StartDt, EndDt); gvReports.DataSource = ds; gvReports.DataBind(); if (ds.Tables[0].Rows.Count < 1) { lblSubMsg.Visible = true; } } else { pnlgrid.Visible = true; BA_Timesheet batime = new BA_Timesheet(); DataSet ds = new DataSet(); string User = ddlUser.SelectedValue.ToString(); string StartDt = txtStartDate.Text; string EndDt = txtEndDate.Text; ds = batime.GetUserReports(id, User, StartDt, EndDt); gvReports.DataSource = ds; gvReports.DataBind(); if (ds.Tables[0].Rows.Count < 1) { lblSubMsg.Visible = true; } } }
protected void edittime(object sender, EventArgs e) { string sid = ddlusers.SelectedValue; using (GridViewRow row = (GridViewRow)((LinkButton)sender).Parent.Parent) { string ids = row.Cells[0].Text; DataSet ds3 = new DataSet(); BA_Timesheet batine = new BA_Timesheet(); ds3 = batine.GetTimes(sid, ids); ddlDayType.SelectedValue = ds3.Tables[0].Rows[0]["worktype"].ToString(); ddlday.SelectedValue = ds3.Tables[0].Rows[0]["Day"].ToString(); string timein = ds3.Tables[0].Rows[0]["timein"].ToString(); if (timein == "Holiday" || timein == "Leave" || timein == "") { ddlday.SelectedValue = ds3.Tables[0].Rows[0]["Day"].ToString(); } else { DateTime dttime = DateTime.Parse(timein); MKB.TimePicker.TimeSelector.AmPmSpec am_pm; if (dttime.ToString("tt") == "AM") { am_pm = MKB.TimePicker.TimeSelector.AmPmSpec.AM; } else { am_pm = MKB.TimePicker.TimeSelector.AmPmSpec.PM; } tsTimeIn.SetTime(dttime.Hour, dttime.Minute, am_pm); } string timeout = ds3.Tables[0].Rows[0]["timeout"].ToString(); if (timeout == "Holiday" || timeout == "Leave" || timeout == "") { ddlday.SelectedValue = ds3.Tables[0].Rows[0]["Day"].ToString(); } else { DateTime dtttimeout = DateTime.Parse(timeout); MKB.TimePicker.TimeSelector.AmPmSpec am_pm1; if (dtttimeout.ToString("tt") == "AM") { am_pm1 = MKB.TimePicker.TimeSelector.AmPmSpec.AM; } else { am_pm1 = MKB.TimePicker.TimeSelector.AmPmSpec.PM; } tsTimeOut.SetTime(dtttimeout.Hour, dtttimeout.Minute, am_pm1); } //ddlday.DataTextField = ds3.Tables[0].Rows[0]["Day"].ToString(); //ddlDayType.SelectedValue = ds3.Tables[0].Rows[0]["worktype"].ToString(); } }
protected void GetTimeSheetInfo(string id) { BA_Timesheet batine = new BA_Timesheet(); DataSet ds1 = new DataSet(); ds1 = batine.GetUsers(id); ddlusers.DataSource = ds1; ddlusers.DataTextField = "firstname"; ddlusers.DataValueField = "Consultantid"; ddlusers.DataBind(); ddlusers.Items.Insert(0, new ListItem("--Select--", "--Select--")); }
protected void btnSubmit_Click(object sender, EventArgs e) { string company = Session["PSEName"].ToString(); BA_Timesheet batine = new BA_Timesheet(); //DateTime x = Convert.ToDateTime(tsTimeIn.Hour.ToString() + ":" + tsTimeIn.Minute.ToString() + tsTimeIn.AmPm); //DateTime y = Convert.ToDateTime(tsTimeOut.Hour.ToString() + ":" + tsTimeOut.Minute.ToString() + tsTimeOut.AmPm); string x = tsTimeIn.Hour.ToString() + ":" + tsTimeIn.Minute.ToString() + tsTimeIn.AmPm; string y = tsTimeOut.Hour.ToString() + ":" + tsTimeOut.Minute.ToString() + tsTimeOut.AmPm; TimeSpan timediff = Convert.ToDateTime(y) - Convert.ToDateTime(x); string timedif = timediff.ToString(); string[] ar = timedif.Split(':'); string[] total; string tt = string.Empty; int cnt = 0; foreach (string t in ar) { if (cnt < 2) { tt = tt + t.ToString() + '.'; cnt++; } } tt = tt.Remove(tt.Length - 1, 1); string totalwork = tt.ToString(); //int val=Convert.ToInt16(timediff.ToString()); string d = ddlday.SelectedItem.ToString(); string sid = ddlusers.SelectedValue; string worktype = ddlDayType.SelectedItem.ToString(); //if (worktype=="Working") //{ batine.InsertTimeSheet(x, y, d, sid, totalwork, worktype, company); //} //else if (worktype=="Holiday" || worktype=="Leave") //{ // batine.InsertOff(sid,d,worktype); //} DataSet ds = new DataSet(); string id1 = ddlusers.SelectedValue; //lblEmpName.Text = ddlusers.SelectedItem.ToString(); ds = batine.GetTimeSheetInfo(id1); dlTsdet.DataSource = ds; dlTsdet.DataBind(); }
protected void ddlusers_SelectedIndexChanged(object sender, EventArgs e) { BA_Timesheet batine = new BA_Timesheet(); DataSet ds = new DataSet(); string id1 = ddlusers.SelectedValue; //lblEmpName.Text = ddlusers.SelectedItem.ToString(); ds = batine.GetTimeSheetInfo(id1); dlTsdet.DataSource = ds; dlTsdet.DataBind(); ddlday.DataSource = ds; ddlday.DataTextField = "day"; ddlday.DataValueField = "day"; ddlday.DataBind(); ddlday.Items.Insert(0, new ListItem("--Select--", "--Select--")); pnlgrid.Visible = true; }
protected void Page_Load(object sender, EventArgs e) { lblSubMsg.Visible = false; id = Session["PSEName"].ToString(); if (!Page.IsPostBack) { ddlUser.Enabled = true; BA_Timesheet batime = new BA_Timesheet(); DataSet ds = new DataSet(); ds = batime.GetUsers(id); ddlUser.DataSource = ds; ddlUser.DataTextField = "firstname"; ddlUser.DataValueField = "Consultantid"; ddlUser.DataBind(); ddlUser.Items.Insert(0, new ListItem("--Select--", "--Select--")); ddlUser.Items.Insert(1, new ListItem("All Users", "All Users")); } }
protected void btnImport_Click(object sender, EventArgs e) { DataSet ds1 = new DataSet(); if (ddlUser.SelectedValue == "All Users") { pnlgrid.Visible = true; BA_Timesheet batime = new BA_Timesheet(); string StartDt = txtStartDate.Text; string EndDt = txtEndDate.Text; ds1 = batime.GetCompanyReports(id, StartDt, EndDt); gvReports.DataSource = ds1; gvReports.DataBind(); if (ds1.Tables[0].Rows.Count < 1) { lblSubMsg.Visible = true; } } else { pnlgrid.Visible = true; BA_Timesheet batime = new BA_Timesheet(); string User = ddlUser.SelectedValue.ToString(); string StartDt = txtStartDate.Text; string EndDt = txtEndDate.Text; ds1 = batime.GetUserReports(id, User, StartDt, EndDt); gvReports.DataSource = ds1; gvReports.DataBind(); if (ds1.Tables[0].Rows.Count < 1) { lblSubMsg.Visible = true; } } try { string filename = "Time Sheet Report from '" + txtStartDate.Text + "' to '" + txtEndDate.Text + "'.xls"; string excelHeader = "Time Sheet Report from '" + txtStartDate.Text + "' to '" + txtEndDate.Text + "'"; HttpContext.Current.Response.Clear(); HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ClearHeaders(); HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.ContentType = "application/ms-excel"; HttpContext.Current.Response.Write(@"<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">"); HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename); HttpContext.Current.Response.Charset = "utf-8"; HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("windows-1250"); //sets font //HttpContext.Current.Response.Write("<font style='font-size:10.0pt; font-family:Calibri;'>"); //HttpContext.Current.Response.Write("<BR><BR><BR>"); //sets the table border, cell spacing, border color, font of the text, background, foreground, font height HttpContext.Current.Response.Write("<table style='height:200px;width:100px;'><tr><td style='width:200px;height:100px;'></td></tr><tr><td style='width:200px;'></td><td><Table border='1' borderColor='#000000' style='padding-left:300px'> <TR><td align='center' colspan='" + ds1.Tables[0].Columns.Count + "' style='height:40px; font-weight: bold; font-size: 16px; color:black; background-color:Tan;vertical-align:middle;'>" + excelHeader.ToUpper() + "</td></tr><tr>"); //Getting Dataset's column headers int columnscount = ds1.Tables[0].Columns.Count; for (int j = 0; j < columnscount; j++) { //write in new column HttpContext.Current.Response.Write("<Td style='height:25px; font-weight: bold; font-size: 14px; color:black; background-color:PaleGoldenrod;vertical-align:left;'>"); //Get column headers and make it as bold in excel columns HttpContext.Current.Response.Write("<B>"); HttpContext.Current.Response.Write(ds1.Tables[0].Columns[j].ColumnName.ToString()); HttpContext.Current.Response.Write("</B>"); HttpContext.Current.Response.Write("</Td>"); } HttpContext.Current.Response.Write("</TR>"); foreach (DataRow row in ds1.Tables[0].Rows) { //write in new row HttpContext.Current.Response.Write("<TR >"); for (int i = 0; i < ds1.Tables[0].Columns.Count; i++) { HttpContext.Current.Response.Write("<Td style='height:22px; font-size: 14px; background-color:white; color:black; vertical-align:left;'>"); HttpContext.Current.Response.Write(row[i].ToString()); HttpContext.Current.Response.Write("</Td>"); } HttpContext.Current.Response.Write("</TR>"); } HttpContext.Current.Response.Write("</Table></td></tr></table>"); HttpContext.Current.Response.Write("</font>"); HttpContext.Current.Response.Flush(); HttpContext.Current.Response.End(); } catch (Exception ex) { } }