コード例 #1
0
 protected void btnView_Click(object sender, EventArgs e)//Hien thi History
 {
     try
     {
         if (ddlShift.SelectedValue.Equals("Day"))//hien thi ca ngay
         {
             inputDay_BLL = new LineInput_BLL();
             DateTime datepick = DateTime.ParseExact(datepicker.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
             planid = plan_BLL.findPlanIdByDateTime(datepick);
             setDataField("Day");
             GridView1.DataSource = inputDay_BLL.InputDay_GetAllLines(planid);
             GridView1.DataBind();
             loadFooterGridView();
         }
         else //hien thi ca dem
         {
             inputNight_BLL = new LineNight_BLL();
             DateTime datepick = DateTime.ParseExact(datepicker.Text.Trim(), "dd/MM/yyyy", CultureInfo.InvariantCulture);
             //tim plan Id theo date ben tren
             planid = plan_BLL.findPlanIdByDateTime(datepick);
             //BoundField a = GridView1.Columns[11] as BoundField;
             setDataField("Night");
             //BoundField b = GridView1.Columns[11] as BoundField;
             GridView1.DataSource = inputNight_BLL.InputNight_GetAllLines(planid);
             GridView1.DataBind();
             loadFooterGridViewN();
         }
     }
     catch (Exception ex)
     {
         if (ex is FormatException)
         {
             ScriptManager.RegisterStartupScript(this, GetType(), "showalert", "alert('Error: DateTime is null or incorrect');", true);
         }
         else if (ex is NullReferenceException)
         {
         }
         else
         {
         }
     }
 }