protected void BtnSave_Click(object sender, EventArgs e)
        {
            try
            {
                HRM_MachineReadableProblem objmachineProblem = new HRM_MachineReadableProblem();

                objmachineProblem.RegionId    = Convert.ToInt32(lblRegionId.Text);
                objmachineProblem.OfficeId    = Convert.ToInt32(lblOfficeId.Text);
                objmachineProblem.ShiftCode   = ddlShiftCode.SelectedValue;
                objmachineProblem.ShiftName   = ddlShiftCode.SelectedItem.Text;
                objmachineProblem.Att_Date    = Convert.ToDateTime(txtDate.Text);
                objmachineProblem.Att_Day     = Convert.ToDateTime(txtDate.Text).DayOfWeek.ToString();
                objmachineProblem.Working_Day = ddlWorkingDay.Text;
                objmachineProblem.Remarks     = txtRemarks.Text;

                TimeSpan in_time = TimeSpan.Parse(string.Format("{0}:{1}:{2}", txtStartTime.Hour, txtStartTime.Minute, txtStartTime.Second));
                objmachineProblem.InTime = in_time;

                TimeSpan out_time = TimeSpan.Parse(string.Format("{0}:{1}:{2}", txtEndTime.Hour, txtEndTime.Minute, txtEndTime.Second));
                objmachineProblem.OutTime = out_time;

                objmachineProblem.Edit_User = ((SessionUser)Session["SessionUser"]).UserId;
                objmachineProblem.Edit_Date = DateTime.Now;
                objmachineProblem.OCode     = ((SessionUser)Session["SessionUser"]).OCode;

                if (in_time > out_time)
                {
                    //lblMessage.Text = "<font color='red'>Out Time can't be less than In Time</font>";
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Out Time can't be less than In Time')", true);
                    return;
                }

                objAttendanceBll.InsertMachineProblem(objmachineProblem);

                HRM_ATTENDANCE objAttendance = new HRM_ATTENDANCE();
                objAttendance.ShiftCode       = ddlShiftCode.SelectedValue;
                objAttendance.Attendance_Date = Convert.ToDateTime(txtDate.Text);
                objAttendance.Attendance_Day  = Convert.ToDateTime(txtDate.Text).DayOfWeek.ToString();
                objAttendance.Working_Day     = ddlWorkingDay.Text;
                objAttendance.Remarks         = txtRemarks.Text;
                objAttendance.In_Time         = in_time;
                objAttendance.Out_Time        = out_time;

                objAttendance.Edit_User = ((SessionUser)Session["SessionUser"]).UserId;
                objAttendance.Edit_Date = DateTime.Now;
                objAttendance.OCode     = ((SessionUser)Session["SessionUser"]).OCode;

                var result = objAttendanceBll.InsertAtt_MachineProblem(objAttendance);
                if (result == 1)
                {
                    // lblMessage.Text = "Data Added successfully!";
                    //lblMessage.ForeColor = System.Drawing.Color.Green;
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Added successfully!')", true);
                    reset();
                    BindGridAttendance();
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }