public void Loadplan() { dt = new DataTable(); DataSet ds = new DataSet(); objlaboreff = new laborefficiency(); da = new SqlDataAdapter("select * from laborefficiency", strConnString); //ds = objserver.GetDateset("select * from laborefficiency"); da.Fill(dt); da.Fill(ds); if (ds.Tables[0].Rows.Count > 0) { //Grid_plan.DataSource = ds.Tables[0]; //Grid_plan.DataBind(); if (ds.Tables[0].Rows.Count > 0) { paging.DataSource = dt.DefaultView; if (ds.Tables[0].Rows.Count > 8) { paging.AllowPaging = true; paging.PageSize = 8; paging.CurrentPageIndex = CurrentPage; ViewState["totalpage"] = paging.PageCount; link_previous.Enabled = !paging.IsFirstPage; link_next.Enabled = !paging.IsLastPage; } else { div_paging.Visible = false; } Grid_lbr.DataSource = paging; Grid_lbr.DataBind(); div_labr.Visible = true; div_actualerror.Visible = false; createpaging(); } } else { div_labr.Visible = false; div_actualerror.Visible = true; } }
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { string strDate = txt_date.Value.ToString(); //Format – dd/MM/yyyy //split string date by separator, here I'm using '/' string[] arrDate = strDate.Split('/'); //now use array to get specific date object string month = arrDate[0].ToString(); string month1 = arrDate[0].ToString(); if (month == "01") { month = "Jan"; } else if (month == "02") { month = "Feb"; } else if (month == "03") { month = "Mar"; } else if (month == "04") { month = "Apr"; } else if (month == "05") { month = "May"; } else if (month == "06") { month = "Jun"; } else if (month == "07") { month = "Jul"; } else if (month == "08") { month = "Aug"; } else if (month == "09") { month = "Sep"; } else if (month == "10") { month = "Oct"; } else if (month == "11") { month = "Nov"; } else if (month == "12") { month = "Dec"; } else { } int num = 07; int num1 = 14; int num2 = 21; int num3 = 28; int day = Convert.ToInt32(arrDate[1].ToString()); string day1 = arrDate[1].ToString(); if (Convert.ToInt32(day) <= Convert.ToInt32(num)) { day1 = "week1"; } else if ((Convert.ToInt32(day) >= Convert.ToInt32(num)) && (Convert.ToInt32(day) <= Convert.ToInt32(num1))) { day1 = "week2"; } else if ((Convert.ToInt32(day) >= Convert.ToInt32(num)) && (Convert.ToInt32(day) >= Convert.ToInt32(num1)) && (Convert.ToInt32(day) <= Convert.ToInt32(num2))) { day1 = "week3"; } else if ((Convert.ToInt32(day) >= Convert.ToInt32(num)) && (Convert.ToInt32(day) >= Convert.ToInt32(num1)) && (Convert.ToInt32(day) >= Convert.ToInt32(num2)) && (Convert.ToInt32(day) <= Convert.ToInt32(num3))) { day1 = "week4"; } string year = arrDate[2].ToString(); objlaboreff = new laborefficiency(); objlaboreff.LDate = txt_date.Value.ToString(); objlaboreff.Lmonth_num = month1.ToString(); objlaboreff.Lmonth = month.ToString(); objlaboreff.Lday = day.ToString(); objlaboreff.Lweek = day1.ToString(); objlaboreff.Lyear = year.ToString(); objlaboreff.Lshift = ddl_shift.SelectedItem.Text.ToString(); objlaboreff.earn_time = Text_earn.Value.ToString(); objlaboreff.actual_time = Text_actual.Value.ToString(); objlaboreff.unit = ddl_unit_LBeff.Text.ToString(); objlaboreff.MachineName = Slct_machine_eff_LE.Value.ToString(); if (ttl_tim.Value != "") { objlaboreff.total_time = Convert.ToInt32(ttl_tim.Value.ToString()); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "key", "actualtym();", true); return; //ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "alert(' !');", true); } objQualitySheetdclassDataContext.laborefficiencies.InsertOnSubmit(objlaboreff); objQualitySheetdclassDataContext.SubmitChanges(); objQualitySheetdclassDataContext = null; ClientScript.RegisterStartupScript(Page.GetType(), "mykey", "alert('Data Submitted Successfuly !');", true); clear(); Loadplan(); }