protected void btnProcess_Click(object sender, EventArgs e)
        {
            try
            {
                string OCODE = Convert.ToString(((SessionUser)Session["SessionUser"]).OCode);

                HRM_OfficialDay_Individual OfficialDayIndvidual = new HRM_OfficialDay_Individual();
                OfficialDayIndvidual.Official_Date = Convert.ToDateTime(txtDate.Text);
                OfficialDayIndvidual.Working_Day   = ddlday.Text;
                OfficialDayIndvidual.OT_Applicable = Convert.ToBoolean(ddlOT.SelectedValue);
                OfficialDayIndvidual.Edit_User     = ((SessionUser)Session["SessionUser"]).UserId;
                OfficialDayIndvidual.Edit_Date     = DateTime.Now;
                OfficialDayIndvidual.OCode         = OCODE;
                OfficialDayIndvidual.EID           = txtEid_TRNS.Text;

                var result = objAtt_BLL.GetAllOfficeDayById(OCODE, txtEid_TRNS.Text, Convert.ToDateTime(txtDate.Text));
                if (result.Count > 0)
                {
                    objAtt_BLL.UpdateOffialTypeById(OfficialDayIndvidual, Convert.ToDateTime(txtDate.Text), txtEid_TRNS.Text);  //update working day
                }
                else
                {
                    objAtt_BLL.InsertOfficeTypeIndividual(OfficialDayIndvidual);
                }

                HRM_ATTENDANCE attendanceDay = new HRM_ATTENDANCE();
                attendanceDay.Working_Day = ddlday.Text;



                var result1 = objAtt_BLL.UpdateAtt_WorkingDayById(OCODE, txtEid_TRNS.Text, txtDate.Text, ddlday.Text);
                if (result1 == 1)
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Successfully')", true);
                    //lblMessage.Text = "Data Update successfully!";
                    //lblMessage.ForeColor = System.Drawing.Color.Green;
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updating Error!')", true);
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
Beispiel #2
0
        protected void btn_Confirm_Clcik(object sender, EventArgs e)
        {
            try
            {
                string   OCODE       = ((SessionUser)Session["SessionUser"]).OCode;
                DateTime EDIT_DATE   = DateTime.Now;
                Guid     userId      = ((SessionUser)Session["SessionUser"]).UserId;
                DateTime workingDate = Convert.ToDateTime(txtDate.Text);
                string   Attdate     = Convert.ToString(txtDate.Text);

                List <HRM_OfficialDay_Individual> lstHRM_OfficialDay_Individual = new List <HRM_OfficialDay_Individual>();

                if (ckIndividualWorkingDay.Checked) // individual working day type change
                {
                    if (txtbxEID.Text == "")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Enter E-ID!')", true);
                        return;
                    }
                    if (txtDate.Text == "")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Working Date!')", true);
                        return;
                    }
                    if (ddlworkingType.SelectedItem.Text == "------ Select One ------")
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Select Working Day!')", true);
                        return;
                    }

                    HRM_OfficialDay_Individual aHRM_OfficialDay_Individual = new HRM_OfficialDay_Individual();

                    string eid        = txtbxEID.Text;
                    string workingDay = ddlworkingType.Text;

                    var getdata = objAtt_BLL.GetAllOfficeDayById(OCODE, eid, Convert.ToDateTime(txtDate.Text));

                    var getAttendancedata = objAtt_BLL.GetAttendanceByEID_Date(OCODE, eid, Convert.ToDateTime(txtDate.Text));

                    if (getdata.Count() == 0)   //insert
                    {
                        aHRM_OfficialDay_Individual.EID           = txtbxEID.Text;
                        aHRM_OfficialDay_Individual.Official_Date = Convert.ToDateTime(txtDate.Text);
                        aHRM_OfficialDay_Individual.Working_Day   = workingDay;
                        aHRM_OfficialDay_Individual.OCode         = OCODE;
                        aHRM_OfficialDay_Individual.Edit_Date     = EDIT_DATE;
                        aHRM_OfficialDay_Individual.Edit_User     = userId;

                        lstHRM_OfficialDay_Individual.Add(aHRM_OfficialDay_Individual);

                        _context.HRM_OfficialDay_Individual.AddObject(aHRM_OfficialDay_Individual);

                        _context.SaveChanges();  // insert working day type

                        if (getAttendancedata.Count > 0)
                        {
                            HRM_ATTENDANCE aHRM_ATTENDANCE = new HRM_ATTENDANCE();

                            DateTime date = Convert.ToDateTime(Attdate);
                            aHRM_ATTENDANCE = _context.HRM_ATTENDANCE.Where(c => c.EID == eid && c.Attendance_Date == date).First();

                            aHRM_ATTENDANCE.Update_Status = 0;
                            aHRM_ATTENDANCE.OCode         = OCODE;
                            aHRM_ATTENDANCE.Edit_Date     = EDIT_DATE;
                            aHRM_ATTENDANCE.Edit_User     = userId;

                            _context.SaveChanges();   // update attendance update status

                            // update attendnace status by date
                            aAttendance_RPT_Bll.UpdateAll_AttStatus_ByDate(Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text));

                            //insert/update leave/holiday attendnace status process by selected eid
                            aAttendance_RPT_Bll.Insert_Update_AbsentLeaveStatus_ByDate_EID2(lstHRM_OfficialDay_Individual, Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text));

                            //ot process

                            List <string> ShiftCodes = objAtt_BLL.GetAllShiftCode(OCODE).ToList();

                            foreach (string ashiftcode in ShiftCodes)
                            {
                                objAtt_BLL.UpdateOT_ByDateandShift(Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text), ashiftcode);
                            }

                            //ot process log
                            var    ParamempID1 = new SqlParameter("@DateFrom", Convert.ToDateTime(txtDate.Text));
                            var    ParamempID2 = new SqlParameter("@DateTo", Convert.ToDateTime(txtDate.Text));
                            var    ParamempID3 = new SqlParameter("@Edit_User", userId);
                            var    ParamempID4 = new SqlParameter("@Edit_Date", DateTime.Now);
                            var    ParamempID5 = new SqlParameter("@OCODE", OCODE);
                            string SP_SQL      = "HRM_Insert_OTProcessLog @DateFrom, @DateTo, @Edit_User, @Edit_Date, @OCODE";
                            _context.ExecuteStoreCommand(SP_SQL, ParamempID1, ParamempID2, ParamempID3, ParamempID4, ParamempID5);
                        }

                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Processed Successfully')", true);

                        grdview.DataSource = null;
                        grdview.DataBind();
                    }

                    else  //update
                    {
                        HRM_OfficialDay_Individual _HRM_OfficialDay_Individual = new HRM_OfficialDay_Individual();

                        _HRM_OfficialDay_Individual = _context.HRM_OfficialDay_Individual.Where(c => c.EID == eid).First();

                        _HRM_OfficialDay_Individual.Working_Day   = workingDay;
                        _HRM_OfficialDay_Individual.OCode         = OCODE;
                        _HRM_OfficialDay_Individual.Edit_Date     = EDIT_DATE;
                        _HRM_OfficialDay_Individual.Edit_User     = userId;
                        _HRM_OfficialDay_Individual.Official_Date = Convert.ToDateTime(txtDate.Text);

                        lstHRM_OfficialDay_Individual.Add(_HRM_OfficialDay_Individual);

                        int result = objAtt_BLL.UpdateWorkingDay(lstHRM_OfficialDay_Individual); // update working day type

                        if (result == 1)
                        {
                            if (getAttendancedata.Count > 0)
                            {
                                HRM_ATTENDANCE aHRM_ATTENDANCE = new HRM_ATTENDANCE();
                                DateTime       date            = Convert.ToDateTime(Attdate);
                                aHRM_ATTENDANCE = _context.HRM_ATTENDANCE.Where(c => c.EID == eid && c.Attendance_Date == date).First();

                                aHRM_ATTENDANCE.Update_Status = 0;
                                aHRM_ATTENDANCE.OCode         = OCODE;
                                aHRM_ATTENDANCE.Edit_Date     = EDIT_DATE;
                                aHRM_ATTENDANCE.Edit_User     = userId;

                                _context.SaveChanges();   // update attendnace update status

                                // update attendnace status by date
                                aAttendance_RPT_Bll.UpdateAll_AttStatus_ByDate(Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text));

                                //insert/update leave/holiday attendnace status process by selected eid
                                aAttendance_RPT_Bll.Insert_Update_AbsentLeaveStatus_ByDate_EID2(lstHRM_OfficialDay_Individual, Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text));

                                //ot process

                                List <string> ShiftCodes = objAtt_BLL.GetAllShiftCode(OCODE).ToList();

                                foreach (string ashiftcode in ShiftCodes)
                                {
                                    objAtt_BLL.UpdateOT_ByDateandShift(Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text), ashiftcode);
                                }

                                //ot process log
                                var    ParamempID1 = new SqlParameter("@DateFrom", Convert.ToDateTime(txtDate.Text));
                                var    ParamempID2 = new SqlParameter("@DateTo", Convert.ToDateTime(txtDate.Text));
                                var    ParamempID3 = new SqlParameter("@Edit_User", userId);
                                var    ParamempID4 = new SqlParameter("@Edit_Date", DateTime.Now);
                                var    ParamempID5 = new SqlParameter("@OCODE", OCODE);
                                string SP_SQL      = "HRM_Insert_OTProcessLog @DateFrom, @DateTo, @Edit_User, @Edit_Date, @OCODE";
                                _context.ExecuteStoreCommand(SP_SQL, ParamempID1, ParamempID2, ParamempID3, ParamempID4, ParamempID5);
                            }
                            grdview.DataSource = null;
                            grdview.DataBind();
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Processed Successfully')", true);
                        }
                        else
                        {
                            ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Processing Faliure!')", true);
                        }
                    }
                    ClearUI();
                }

                else  // dept/section/subsection wise working day type change
                {
                    if (grdview.Rows.Count < 0)
                    {
                        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('No Employee selected in the list!')", true);
                        return;
                    }

                    foreach (GridViewRow gvRow in grdview.Rows)
                    {
                        CheckBox rowChkBox = ((CheckBox)gvRow.FindControl("rowLevelCheckBox"));

                        HRM_OfficialDay_Individual aHRM_OfficialDay_Individual = new HRM_OfficialDay_Individual();

                        Label  lblEID = ((Label)gvRow.FindControl("lblEID"));
                        string eid    = lblEID.Text.ToString();

                        DropDownList ddlworking_Day = ((DropDownList)gvRow.FindControl("ddlworking_Day"));
                        string       workingDay     = ddlworking_Day.Text;

                        var getdata = objAtt_BLL.GetAllOfficeDayById(OCODE, eid, Convert.ToDateTime(txtDate.Text));

                        //var getAttendancedata = objAtt_BLL.GetAttendanceByEID_Date(OCODE, eid, Convert.ToDateTime(txtDate.Text));

                        if (rowChkBox.Checked == true)
                        {
                            if (getdata.Count() == 0) //insert
                            {
                                aHRM_OfficialDay_Individual.EID           = lblEID.Text;
                                aHRM_OfficialDay_Individual.Official_Date = Convert.ToDateTime(txtDate.Text);
                                aHRM_OfficialDay_Individual.Working_Day   = workingDay;
                                aHRM_OfficialDay_Individual.OCode         = OCODE;
                                aHRM_OfficialDay_Individual.Edit_Date     = EDIT_DATE;
                                aHRM_OfficialDay_Individual.Edit_User     = userId;

                                lstHRM_OfficialDay_Individual.Add(aHRM_OfficialDay_Individual);

                                _context.HRM_OfficialDay_Individual.AddObject(aHRM_OfficialDay_Individual);

                                _context.SaveChanges(); //insert

                                //if (getAttendancedata.Count > 0)
                                //{
                                //foreach (var aHRM_ATTENDANCE in _context.HRM_ATTENDANCE.Where(x => x.EID == eid && x.Attendance_Date == workingDate))
                                //{
                                //    aHRM_ATTENDANCE.Update_Status = 0;
                                //    aHRM_ATTENDANCE.OCode = OCODE;
                                //    aHRM_ATTENDANCE.Edit_Date = EDIT_DATE;
                                //    aHRM_ATTENDANCE.Edit_User = userId;
                                //}
                                //_context.CommandTimeout = 1000;
                                //_context.SaveChanges();


                                //HRM_ATTENDANCE aHRM_ATTENDANCE = new HRM_ATTENDANCE();
                                //DateTime date = Convert.ToDateTime(Attdate);
                                //aHRM_ATTENDANCE = _context.HRM_ATTENDANCE.Where(c => c.EID == eid && c.Attendance_Date == date).First();

                                //aHRM_ATTENDANCE.Update_Status = 0;
                                //aHRM_ATTENDANCE.OCode = OCODE;
                                //aHRM_ATTENDANCE.Edit_Date = EDIT_DATE;
                                //aHRM_ATTENDANCE.Edit_User = userId;

                                //_context.SaveChanges();

                                //aAttendance_RPT_Bll.UpdateAll_AttStatus_ByDate(Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text)); // update attendnace status by date

                                //insert/update leave/holiday attendnace status process by selected eid
                                //aAttendance_RPT_Bll.Insert_Update_AbsentLeaveStatus_ByDate_EID2(lstHRM_OfficialDay_Individual, Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text));

                                //ot process

                                //List<string> ShiftCodes = objAtt_BLL.GetAllShiftCode(OCODE).ToList();

                                //foreach (string ashiftcode in ShiftCodes)
                                //{
                                //    objAtt_BLL.UpdateOT_ByDateandShift(Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text), ashiftcode);
                                //}

                                ////ot process log
                                //var ParamempID1 = new SqlParameter("@DateFrom", Convert.ToDateTime(txtDate.Text));
                                //var ParamempID2 = new SqlParameter("@DateTo", Convert.ToDateTime(txtDate.Text));
                                //var ParamempID3 = new SqlParameter("@Edit_User", userId);
                                //var ParamempID4 = new SqlParameter("@Edit_Date", DateTime.Now);
                                //var ParamempID5 = new SqlParameter("@OCODE", OCODE);
                                //string SP_SQL = "HRM_Insert_OTProcessLog @DateFrom, @DateTo, @Edit_User, @Edit_Date, @OCODE";
                                //_context.ExecuteStoreCommand(SP_SQL, ParamempID1, ParamempID2, ParamempID3, ParamempID4, ParamempID5);
                                //}

                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Processed Successfully')", true);

                                grdview.DataSource = null;
                                grdview.DataBind();
                            }
                            else  //update
                            {
                                foreach (var _HRM_OfficialDay_Individual in _context.HRM_OfficialDay_Individual.Where(x => x.EID == eid && x.Official_Date == workingDate))
                                {
                                    _HRM_OfficialDay_Individual.Working_Day = workingDay;
                                    _HRM_OfficialDay_Individual.OCode       = OCODE;
                                    _HRM_OfficialDay_Individual.Edit_Date   = EDIT_DATE;
                                    _HRM_OfficialDay_Individual.Edit_User   = userId;

                                    lstHRM_OfficialDay_Individual.Add(_HRM_OfficialDay_Individual);
                                }

                                _context.SaveChanges();

                                //if (getAttendancedata.Count > 0)
                                //{
                                //foreach (var aHRM_ATTENDANCE in _context.HRM_ATTENDANCE.Where(x => x.EID == eid && x.Attendance_Date == workingDate))
                                //{
                                //    aHRM_ATTENDANCE.Update_Status = 0;
                                //    aHRM_ATTENDANCE.OCode = OCODE;
                                //    aHRM_ATTENDANCE.Edit_Date = EDIT_DATE;
                                //    aHRM_ATTENDANCE.Edit_User = userId;
                                //}
                                // _context.CommandTimeout = 1000;
                                //_context.SaveChanges();

                                //HRM_ATTENDANCE aHRM_ATTENDANCE = new HRM_ATTENDANCE();
                                //DateTime date = Convert.ToDateTime(Attdate);
                                //aHRM_ATTENDANCE = _context.HRM_ATTENDANCE.Where(c => c.EID == eid && c.Attendance_Date == date).First();

                                //aHRM_ATTENDANCE.Update_Status = 0;
                                //aHRM_ATTENDANCE.OCode = OCODE;
                                //aHRM_ATTENDANCE.Edit_Date = EDIT_DATE;
                                //aHRM_ATTENDANCE.Edit_User = userId;

                                //_context.SaveChanges();

                                // update attendnace status by date
                                //aAttendance_RPT_Bll.UpdateAll_AttStatus_ByDate(Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text));

                                //insert/update leave/holiday attendnace status process by selected eid
                                //aAttendance_RPT_Bll.Insert_Update_AbsentLeaveStatus_ByDate_EID2(lstHRM_OfficialDay_Individual, Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text));

                                //ot process

                                //List<string> ShiftCodes = objAtt_BLL.GetAllShiftCode(OCODE).ToList();

                                //foreach (string ashiftcode in ShiftCodes)
                                //{
                                //    objAtt_BLL.UpdateOT_ByDateandShift(Convert.ToDateTime(txtDate.Text), Convert.ToDateTime(txtDate.Text), ashiftcode);
                                //}

                                ////ot process log
                                //var ParamempID1 = new SqlParameter("@DateFrom", Convert.ToDateTime(txtDate.Text));
                                //var ParamempID2 = new SqlParameter("@DateTo", Convert.ToDateTime(txtDate.Text));
                                //var ParamempID3 = new SqlParameter("@Edit_User", userId);
                                //var ParamempID4 = new SqlParameter("@Edit_Date", DateTime.Now);
                                //var ParamempID5 = new SqlParameter("@OCODE", OCODE);
                                //string SP_SQL = "HRM_Insert_OTProcessLog @DateFrom, @DateTo, @Edit_User, @Edit_Date, @OCODE";
                                //_context.ExecuteStoreCommand(SP_SQL, ParamempID1, ParamempID2, ParamempID3, ParamempID4, ParamempID5);
                                //}

                                grdview.DataSource = null;
                                grdview.DataBind();
                                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('Data Updated Successfully')", true);
                            }
                        }
                    }
                    //_context.SaveChanges();
                    ClearUI();
                }
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "text", "func('" + ex.Message + "')", true);
            }
        }
Beispiel #3
0
 public int InsertOfficeTypeIndividual(HRM_OfficialDay_Individual objOfficialDay)
 {
     return(objCtx_DAL.InsertOfficeTypeIndividual(objOfficialDay));
 }
Beispiel #4
0
 internal int UpdateOffialTypeById(HRM_OfficialDay_Individual objOfficialDay, DateTime Official_Date, string Eid)
 {
     return(objCtx_DAL.UpdateOffialTypeById(objOfficialDay, Official_Date, Eid));
 }