protected void btnUpdatePwd_Click(object sender, EventArgs e)
        {
            try
            {
                string location = Session["LocationName"].ToString();
                string EmpName = Session["EmpName"].ToString().Trim();
                int userid = Convert.ToInt32(Session["UserID"]);
                string oldPwd = txtOldpwd.Text.Trim();
                string NewPwd = txtNewPwd.Text.Trim();
                Attendance.BAL.EmployeeBL obj = new EmployeeBL();
                bool bnew = obj.UpdatePasswordByUserID(userid, oldPwd, NewPwd);
                if (bnew)
                {
                    txtOldpwd.Text = "";
                    txtNewPwd.Text = "";
                    txtConfirmPwd.Text = "";
                    mdlChangePwd.Hide();
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('Password changed successfully..');", true);
                }
                else
                {
                    txtOldpwd.Text = "";
                    txtNewPwd.Text = "";
                    txtConfirmPwd.Text = "";
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('Invalid userid and password..');", true);
                    txtOldpwd.Focus();
                }

            }
            catch (Exception ex)
            {
            }
        }
        protected void btnApply_Click(object sender, EventArgs e)
        {
            try
            {
                int holidayID =hdnHolidayID.Value==""?0:Convert.ToInt32(hdnHolidayID.Value);
                DateTime HolidayDt = Convert.ToDateTime(hdnHolidayDt.Value);
                string Holidayname =GeneralFunction.ToProper(txtHolidayName.Text.Trim());
                bool IsHoliday = true;
                if (rdWorkingday.Checked)
                {
                    IsHoliday = false;
                }
                int DeptID = 0;
                if (ddlPopDept.SelectedItem.Value != "0")
                {
                    DeptID = Convert.ToInt32(ddlPopDept.SelectedItem.Value);
                }
                int LocationID = 0;
                if (ddlPopLoc.SelectedItem.Value != "0")
                {
                    LocationID = Convert.ToInt32(ddlPopLoc.SelectedItem.Value);
                }
                string shiftName ="0";
                if (ddlHolshift.SelectedItem.Value != "0")
                {
                    shiftName = ddlHolshift.SelectedItem.Value.ToString();
                }
                int EnterBy = Convert.ToInt32(Session["UserID"]);
                string timezone = "";
                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";
                }
                DateTime Enterdate = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));
                String strHostName = Request.UserHostAddress.ToString();
                string IpAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

                EmployeeBL obj = new EmployeeBL();
                if (holidayID == 0)
                {
                    bool bnew = obj.SaveandGetHolidayDet(IsHoliday, HolidayDt, LocationID, DeptID, shiftName, EnterBy, Enterdate, IpAddress, Holidayname, false);
                }
                else
                {
                    bool bnew = obj.UpdateHolidayDet(IsHoliday, holidayID, LocationID, DeptID, shiftName, EnterBy, Enterdate, IpAddress);
                }
                GetCalender(Convert.ToDateTime(Session["MonthHolStart"]),Convert.ToDateTime(Session["MonthHolEnd"]),Convert.ToInt32(ddlLocation.SelectedItem.Value),Convert.ToInt32(ddlShift.SelectedValue),Convert.ToInt32(ddlDepartment.SelectedValue));
                mdlHoliday.Hide();
            }
            catch (Exception ex)
            {
            }
        }
 protected void grdUsers_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     EmployeeBL obj = new EmployeeBL();
     PayrollEditHistory objPay = new PayrollEditHistory();
     try
     {
         if (e.CommandName == "Effective")
         {
             int EffectiveID = Convert.ToInt32(e.CommandArgument.ToString());
             DataTable dt = obj.GetEmpChangesEffectiveByID(EffectiveID);
             hdnEffectID.Value = dt.Rows[0]["EffectiveID"].ToString();
             lblEmpName.Text = dt.Rows[0]["empname"].ToString() + " - " + dt.Rows[0]["empID"].ToString();
             lblFieldname.Text = dt.Rows[0]["ChangeField"].ToString();
             lblEditFieldName.Text = dt.Rows[0]["ChangeField"].ToString();
             lblOldValue.Text = objPay.GetName(dt.Rows[0]["ChangeField"].ToString(), dt.Rows[0]["OldValue"].ToString());
             lblEditOldValue.Text = objPay.GetName(dt.Rows[0]["ChangeField"].ToString(), dt.Rows[0]["OldValue"].ToString());
             lblNewvalue.Text = objPay.GetName(dt.Rows[0]["ChangeField"].ToString(), dt.Rows[0]["NewValue"].ToString());
             lblEffectiveDt.Text = Convert.ToDateTime(dt.Rows[0]["EffectiveDt"].ToString()).ToString("MM/dd/yyyy");
             txtEffectiveDate.Text = Convert.ToDateTime(dt.Rows[0]["EffectiveDt"].ToString()).ToString("MM/dd/yyyy");
             lblStatus.Text = dt.Rows[0]["ChangeStatus"].ToString();
             ddlEditStatus.SelectedIndex = ddlEditStatus.Items.IndexOf(ddlEditStatus.Items.FindByValue(dt.Rows[0]["StatusID"].ToString()));
             dvView.Style["display"] = "block";
             dvEdit.Style["display"] = "none";
             if (lblFieldname.Text == "Salary")
             {
                 lblOldValue.Text = GeneralFunction.FormatCurrency(lblOldValue.Text, ddlLocation.SelectedItem.Text);
                 lblEditOldValue.Text = GeneralFunction.FormatCurrency(lblEditOldValue.Text, ddlLocation.SelectedItem.Text);
                 lblNewvalue.Text = GeneralFunction.FormatCurrency(lblNewvalue.Text, ddlLocation.SelectedItem.Text);
             }
             GetNamesList(lblEditFieldName.Text, dt);
             mdlAddPopUp.Show();
         }
     }
     catch (Exception ex)
     {
     }
 }
        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                EmployeeBL obj = new EmployeeBL();
                string oldValue = "";
                string newValue = "";
                int effectID = Convert.ToInt32(hdnEffectID.Value);
                oldValue = lblEditOldValue.Text;

                if (txtEditNewValue.Text != "")
                {
                    newValue = txtEditNewValue.Text;
                }
                else
                {
                    newValue = ddlNewValue.SelectedValue;
                }
                DateTime effectDt = txtEffectiveDate.Text == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(txtEffectiveDate.Text);
                int statusID = Convert.ToInt32(ddlEditStatus.SelectedValue);
                bool bnew = obj.UpdateEfectiveChangesByID(effectDt, oldValue, statusID, newValue, effectID);
                mdlAddPopUp.Hide();

                DateTime Start = Convert.ToDateTime(ViewState["StartMonth"]);
                DateTime End = Convert.ToDateTime(ViewState["EndMonth"]);
                GetEffectiveData(Convert.ToInt32(ddlLocation.SelectedValue), Convert.ToInt32(ddlgridShift.SelectedValue),Start, End, Convert.ToInt32(ddlSelect.SelectedValue));
            }
            catch (Exception ex)
            {
            }
        }
        private void GetYear()
        {
            try
            {
                EmployeeBL obj = new EmployeeBL();
                ddlFromYear.DataSource = obj.GetYear();
                ddlFromYear.DataTextField = "year";
                ddlFromYear.DataValueField = "year";
                ddlFromYear.DataBind();
                ddlFromYear.Items.Insert(0, new ListItem("Select", "Select"));
                ddlFromYear.SelectedIndex = ddlFromYear.Items.IndexOf(ddlFromYear.Items.FindByText(System.DateTime.Now.ToString("yyyy")));

                ddlToYear.DataSource = obj.GetYear();
                ddlToYear.DataTextField = "year";
                ddlToYear.DataValueField = "year";
                ddlToYear.DataBind();
                ddlToYear.Items.Insert(0, new ListItem("Select", "Select"));
                ddlToYear.SelectedIndex = ddlToYear.Items.IndexOf(ddlToYear.Items.FindByText(System.DateTime.Now.ToString("yyyy")));
            }
            catch (Exception ex)
            {
            }
        }
        private void GetLeavesDetails(string p, DateTime startdate, DateTime Enddate, int AppovedStatusID,int shiftID)
        {
            try
            {
                EmployeeBL obj = new EmployeeBL();
                DataTable dt = obj.GetLeaveDetailsByLoction(p, startdate, Enddate, AppovedStatusID,shiftID);
                lblMonthRep.Text = "(" + startdate.ToString("MM/dd/yyyy") + " - " + Enddate.ToString("MM/dd/yyyy") + ")";
                if (dt.Rows.Count > 0)
                {
                    grdUsers.DataSource = dt;
                    grdUsers.DataBind();
                    Session["AllLeaveRequestData"] = dt;
                    lblError.Visible = false;
                }
                else
                {
                    lblError.Text = "No records found";
                    lblError.Visible = true;
                }

                BizUtility.GridSortInitail("Ascending", "Firstname", grdUsers, 0, dt);
            }
            catch (Exception ex)
            {
            }
        }
Пример #7
0
        private void GetEmpDet(int empid)
        {
            Attendance.BAL.EmployeeBL obj = new EmployeeBL();
            try
            {
                DataTable dt = obj.GetEmployyeDetailsByUserID(empid);
                hdnUserID.Value = dt.Rows[0]["UserID"].ToString();

                lblEmpID.Text = dt.Rows[0]["EmpID"].ToString();
                lblFirstname.Text = dt.Rows[0]["FirstName"].ToString() + " " + dt.Rows[0]["LastName"].ToString();

                lblBusinessName.Text = dt.Rows[0]["ProfessionalFirstName"].ToString() + " " + dt.Rows[0]["ProfessionalLastName"].ToString();


                hdnFirst.Value = dt.Rows[0]["FirstName"].ToString();
                hdnLastname.Value = dt.Rows[0]["LastName"].ToString();

                hdnBusinessFirst.Value = dt.Rows[0]["ProfessionalFirstName"].ToString();
                hdnBusinessLast.Value = dt.Rows[0]["ProfessionalLastName"].ToString();


                lblEmpType.Text = dt.Rows[0]["MasterEmpType"].ToString();
                lbldepartment.Text = dt.Rows[0]["DeptName"].ToString();
                lblDesignation.Text = dt.Rows[0]["designation"].ToString();
                lblStartDate.Text = dt.Rows[0]["startdate"].ToString().Trim() == "" ? "" : Convert.ToDateTime(dt.Rows[0]["startdate"].ToString()).ToString("MM/dd/yyyy") == "01/01/1900" ? "" : Convert.ToDateTime(dt.Rows[0]["startdate"].ToString()).ToString("MM/dd/yyyy");
                lblActive.Text = dt.Rows[0]["Isactive"].ToString() == "True" ? "Yes" : "No";
                string img = dt.Rows[0]["PhotoLink"].ToString() == "" ? "defaultUSer.jpg" : dt.Rows[0]["PhotoLink"].ToString().Trim();
                imgPhoto.ImageUrl = "~/Photos/" + img;
                if (lblActive.Text == "No")
                {
                    lbltextTermReason.Visible = true;
                    lbltextTermReason.Text = "<b>Term Reason</b>";
                    lblTextTermDt.Visible = true;
                    lblTextTermDt.Text = "<b>Term Dt</b>";
                    lblTermdate.Visible = true;
                    lblTermdate.Text = dt.Rows[0]["TermDate"].ToString().Trim() == "" ? "" : Convert.ToDateTime(dt.Rows[0]["TermDate"].ToString()).ToString("MM/dd/yyyy") == "01/01/1900" ? "" : Convert.ToDateTime(dt.Rows[0]["TermDate"].ToString()).ToString("MM/dd/yyyy");
                    txtTermReason.Visible = true;
                    txtTermReason.Text = dt.Rows[0]["TermReason"].ToString();
                }
                else
                {
                    lbltextTermReason.Visible = false;
                    lblTextTermDt.Visible = false;
                    lblTermdate.Visible = false;
                    txtTermReason.Visible = false;
                }

                lblWageType.Text = dt.Rows[0]["WageType"].ToString();
                ViewState["Salary"] = dt.Rows[0]["Salary"].ToString() == "" ? "" : dt.Rows[0]["Salary"].ToString() == "0.00" ? "" : dt.Rows[0]["Salary"].ToString();
                lblSalary.Text = dt.Rows[0]["Salary"].ToString() == "" ? "" : dt.Rows[0]["Salary"].ToString() == "0.00" ? "" : dt.Rows[0]["Salary"].ToString();
                lblSalary.Text = lblSalary.Text == "" ? "" : GeneralFunction.FormatCurrency(lblSalary.Text, ViewState["Location"].ToString().Trim());
                lblDeuctions.Text = dt.Rows[0]["Deductions"].ToString();
                lblGender.Text = dt.Rows[0]["gender"].ToString();
                lblFilling.Text = dt.Rows[0]["MaritalStatus"].ToString();
                hdnScID.Value = dt.Rows[0]["ScheduleId"].ToString();
                lblSchedule.Text = dt.Rows[0]["StartTime"].ToString() + "-" + dt.Rows[0]["EndTime"].ToString() + " " + "<b>Lunch break: </b>" + dt.Rows[0]["LunchBreakStart"].ToString() + "-" + dt.Rows[0]["LunchBreakEnd"].ToString();
                lblDateofBirth.Text = dt.Rows[0]["dateofbirth"].ToString() == "" ? "" : Convert.ToDateTime(dt.Rows[0]["dateofbirth"].ToString().Trim()).ToString("MM/dd/yyyy") == "01/01/1900" ? "" : Convert.ToDateTime(dt.Rows[0]["dateofbirth"].ToString()).ToString("MM/dd/yyyy");
                lblPhoneNum.Text = dt.Rows[0]["phoneNum"].ToString() == "" ? "" : GeneralFunction.FormatUsTelephoneNo(dt.Rows[0]["phoneNum"].ToString());
                lblMobileNum.Text = dt.Rows[0]["mobileNum"].ToString() == "" ? "" : GeneralFunction.FormatUsTelephoneNo(dt.Rows[0]["mobileNum"].ToString());
                lblBusinessemail.Text = dt.Rows[0]["businessEmail"].ToString();
                lblPersonalEmail.Text = dt.Rows[0]["personalEmail"].ToString();
                lblSSN.Text = GeneralFunction.FormatUsSSN(dt.Rows[0]["ssn"].ToString());

                lblAddress.Text = dt.Rows[0]["Address1"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["Address1"].ToString());
                txtAddress1.Text = dt.Rows[0]["Address1"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["Address1"].ToString());

                lblAddress.Text = lblAddress.Text + (dt.Rows[0]["Address2"].ToString() == "" ? "" : "<br/>" + GeneralFunction.ToProperNotes(dt.Rows[0]["Address2"].ToString()));
                txtAddress2.Text = dt.Rows[0]["Address2"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["Address2"].ToString());
                lblAddress.Text = lblAddress.Text + (dt.Rows[0]["StateCode"].ToString() == "UN" ? "" : "<br/>" + dt.Rows[0]["StateCode"].ToString());
                ddlState.SelectedIndex = ddlState.Items.IndexOf(ddlState.Items.FindByValue(dt.Rows[0]["StateID"].ToString()));
                lblAddress.Text = lblAddress.Text + (dt.Rows[0]["zip"].ToString() == "" ? "" : " " + dt.Rows[0]["zip"].ToString());
                txtZip.Text = dt.Rows[0]["zip"].ToString() == "" ? "" : dt.Rows[0]["zip"].ToString();
                lblLicense.Text = dt.Rows[0]["drivingLicenceNum"].ToString();

                lblCn1Address.Text = dt.Rows[0]["P1Address1"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P1Address1"].ToString());
                txtCn1Address1.Text = dt.Rows[0]["P1Address1"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P1Address1"].ToString());
                lblCn1Address.Text = lblCn1Address.Text + (lblCn1Address.Text != "" ? (dt.Rows[0]["P1Address2"].ToString() == "" ? "" : "<br/>" + GeneralFunction.ToProperNotes(dt.Rows[0]["P1Address2"].ToString())) : (dt.Rows[0]["P1Address2"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P1Address2"].ToString())));
                txtCn1Address2.Text = dt.Rows[0]["P1Address2"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P1Address2"].ToString());


                lblCn1Address.Text = lblCn1Address.Text + (lblCn1Address.Text != "" ? (dt.Rows[0]["state1"].ToString() == "UN" ? "" : "<br/>" + dt.Rows[0]["state1"].ToString()) : dt.Rows[0]["state1"].ToString() == "UN" ? "" : dt.Rows[0]["state1"].ToString());
                ddlCn1State.SelectedIndex = ddlCn1State.Items.IndexOf(ddlCn1State.Items.FindByValue(dt.Rows[0]["stateID1"].ToString()));
                lblCn1Address.Text = lblCn1Address.Text + (lblCn1Address.Text != "" ? (dt.Rows[0]["zip1"].ToString() == "" ? "" : " " + dt.Rows[0]["zip1"].ToString()) : (dt.Rows[0]["zip1"].ToString() == "" ? "" : dt.Rows[0]["zip1"].ToString()));
                txtCn1Zip.Text = dt.Rows[0]["zip1"].ToString();


                lblCn1Name.Text = dt.Rows[0]["Person1"].ToString();
                txtCn1Name.Text = dt.Rows[0]["Person1"].ToString();
                lblCn1Phone.Text = dt.Rows[0]["phone1"].ToString() == "" ? "" : GeneralFunction.FormatUsTelephoneNo(dt.Rows[0]["phone1"].ToString());
                txtCn1Phone.Text = lblCn1Phone.Text.Replace("-", "").Trim();
                lblCn1Email.Text = dt.Rows[0]["email1"].ToString();
                txtCn1Email.Text = dt.Rows[0]["email1"].ToString();
                lblCn1Relation.Text = dt.Rows[0]["relation1"].ToString();
                txtCn1Relation.Text = dt.Rows[0]["relation1"].ToString();

                lblCn2Address.Text = dt.Rows[0]["P2Address1"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P2Address1"].ToString());
                txtCn2Address1.Text = dt.Rows[0]["P2Address1"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P2Address1"].ToString());
                lblCn2Address.Text = lblCn2Address.Text + (lblCn2Address.Text != "" ? (dt.Rows[0]["P2Address2"].ToString() == "" ? "" : "<br/>" +GeneralFunction.ToProperNotes(dt.Rows[0]["P2Address2"].ToString())) : (dt.Rows[0]["P2Address2"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P2Address2"].ToString())));
                txtCn2Address2.Text = dt.Rows[0]["P2Address2"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P2Address2"].ToString());
                ddlCn2State.SelectedIndex = ddlCn1State.Items.IndexOf(ddlCn2State.Items.FindByValue(dt.Rows[0]["stateID2"].ToString()));
                lblCn2Address.Text = lblCn2Address.Text + (lblCn2Address.Text != "" ? (dt.Rows[0]["state2"].ToString() == "UN" ? "" : "<br/>" + dt.Rows[0]["state2"].ToString()) : dt.Rows[0]["state2"].ToString() == "UN" ? "" : dt.Rows[0]["state2"].ToString());
                lblCn2Address.Text = lblCn2Address.Text + (lblCn2Address.Text != "" ? (dt.Rows[0]["zip2"].ToString() == "" ? "" : " " + dt.Rows[0]["zip2"].ToString()) : (dt.Rows[0]["zip2"].ToString() == "" ? "" : dt.Rows[0]["zip2"].ToString()));
                txtCn2Zip.Text = dt.Rows[0]["zip2"].ToString();


                lblCn2Name.Text = dt.Rows[0]["Person2"].ToString();
                txtCn2Name.Text = dt.Rows[0]["Person2"].ToString();
                lblCn2Phone.Text = dt.Rows[0]["phone2"].ToString() == "" ? "" : GeneralFunction.FormatUsTelephoneNo(dt.Rows[0]["phone2"].ToString());
                txtCn2Phone.Text = lblCn2Phone.Text.Replace("-", "").Trim();
                lblCn2Relation.Text = dt.Rows[0]["relation2"].ToString();
                txtCn2Relation.Text = dt.Rows[0]["relation2"].ToString();
                lblCn2Email.Text = dt.Rows[0]["email2"].ToString();
                txtCn2Email.Text = dt.Rows[0]["email2"].ToString();


                lblCn3Address.Text = dt.Rows[0]["P3Address1"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P3Address1"].ToString());
                txtCn3Address1.Text = dt.Rows[0]["P3Address1"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P3Address1"].ToString());
                lblCn3Address.Text = lblCn3Address.Text + (lblCn2Address.Text != "" ? (dt.Rows[0]["P3Address2"].ToString() == "" ? "" : "<br/>" +GeneralFunction.ToProperNotes(dt.Rows[0]["P3Address2"].ToString())) : (dt.Rows[0]["P3Address2"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P3Address2"].ToString())));
                txtCn3Address2.Text = dt.Rows[0]["P3Address2"].ToString() == "" ? "" : GeneralFunction.ToProperNotes(dt.Rows[0]["P3Address2"].ToString());

                lblCn3Address.Text = lblCn3Address.Text + (lblCn2Address.Text != "" ? (dt.Rows[0]["state3"].ToString() == "UN" ? "" : "<br/>" + dt.Rows[0]["state3"].ToString()) : dt.Rows[0]["state3"].ToString() == "UN" ? "" : dt.Rows[0]["state3"].ToString());
                ddlCn3State.SelectedIndex = ddlCn1State.Items.IndexOf(ddlCn3State.Items.FindByValue(dt.Rows[0]["stateID3"].ToString()));
                lblCn3Address.Text = lblCn3Address.Text + (lblCn2Address.Text != "" ? (dt.Rows[0]["zip3"].ToString() == "" ? "" : " " + dt.Rows[0]["zip3"].ToString()) : (dt.Rows[0]["zip3"].ToString() == "" ? "" : dt.Rows[0]["zip3"].ToString()));
                txtCn2Zip.Text = dt.Rows[0]["zip3"].ToString();

                lblCn3Name.Text = dt.Rows[0]["Person3"].ToString();
                txtCn3Name.Text = dt.Rows[0]["Person3"].ToString();
                txtCn3Phone.Text = dt.Rows[0]["phone3"].ToString();
                lblCn3Phone.Text = dt.Rows[0]["phone3"].ToString() == "" ? "" : GeneralFunction.FormatUsTelephoneNo(dt.Rows[0]["phone3"].ToString());
                lblCn3Relation.Text = dt.Rows[0]["relation3"].ToString();
                txtCn3Relation.Text = dt.Rows[0]["relation3"].ToString();
                lblCn3Email.Text = dt.Rows[0]["email3"].ToString();
                txtCn3Email.Text = dt.Rows[0]["email3"].ToString();
            }
            catch (Exception ex)
            {
            }
        }
        private void GetNamesList(string Fieldname, DataTable dt)
        {
            try
            {

                if (Fieldname == "Department")
                {
                    Attendance.BAL.Report obj = new Report();
                    DataTable ds = obj.GetAllDepartments();

                    ddlNewValue.DataSource = ds;
                    ddlNewValue.DataTextField = "DeptName";
                    ddlNewValue.DataValueField = "DeptID";
                    ddlNewValue.DataBind();
                    ddlNewValue.SelectedIndex = ddlNewValue.Items.IndexOf(ddlNewValue.Items.FindByValue(dt.Rows[0]["NewValue"].ToString()));
                    txtEditNewValue.Visible = false;
                    ddlNewValue.Visible = true;
                }

                else if (Fieldname == "Location")
                {
                    Attendance.BAL.Report obj = new Report();
                    DataTable ds = obj.GetLocations();

                    ddlNewValue.DataSource = ds;
                    ddlNewValue.DataTextField = "LocationName";
                    ddlNewValue.DataValueField = "LocationId";
                    ddlNewValue.DataBind();
                    ddlNewValue.SelectedIndex = ddlNewValue.Items.IndexOf(ddlNewValue.Items.FindByValue(dt.Rows[0]["NewValue"].ToString()));
                    txtEditNewValue.Visible = false;
                    ddlNewValue.Visible = true;
                }
                else if (Fieldname == "Schedule")
                {
                    Attendance.BAL.Report obj = new Attendance.BAL.Report();
                    DataTable ds = obj.GetAllScheduleTypes();

                    ddlNewValue.DataSource = ds;
                    ddlNewValue.DataValueField = "ScheduleID";
                    ddlNewValue.DataTextField = "ScheduleType";
                    ddlNewValue.DataBind();

                    ddlNewValue.SelectedIndex = ddlNewValue.Items.IndexOf(ddlNewValue.Items.FindByValue(dt.Rows[0]["NewValue"].ToString()));
                    txtEditNewValue.Visible = false;
                    ddlNewValue.Visible = true;
                }

                else if (Fieldname == "State")
                {
                    Attendance.BAL.Business obj = new Attendance.BAL.Business();
                    DataTable ds = obj.GetState();

                    ddlNewValue.DataSource = ds;
                    ddlNewValue.DataValueField = "StateID";
                    ddlNewValue.DataTextField = "StateName";
                    ddlNewValue.DataBind();

                    ddlNewValue.SelectedIndex = ddlNewValue.Items.IndexOf(ddlNewValue.Items.FindByValue(dt.Rows[0]["NewValue"].ToString()));

                    txtEditNewValue.Visible = false;
                    ddlNewValue.Visible = true;
                }
                else if (Fieldname == "Wage")
                {
                    Attendance.BAL.Report obj = new Attendance.BAL.Report();
                    DataTable ds = obj.GetAllWages();

                    ddlNewValue.DataSource = ds;
                    ddlNewValue.DataValueField = "WageID";
                    ddlNewValue.DataTextField = "WageType";
                    ddlNewValue.DataBind();

                    txtEditNewValue.Visible = false;

                    ddlNewValue.Visible = true;

                    ddlNewValue.SelectedIndex = ddlNewValue.Items.IndexOf(ddlNewValue.Items.FindByValue(dt.Rows[0]["NewValue"].ToString()));
                }
                else if (Fieldname == "Employee type")
                {
                    Attendance.BAL.Report obj = new Attendance.BAL.Report();
                    DataTable ds = obj.GetAllEmployeetypes();

                    ddlNewValue.DataSource = ds;
                    ddlNewValue.DataValueField = "EmpType";
                    ddlNewValue.DataTextField = "EmpTypeID";
                    ddlNewValue.DataBind();

                    ddlNewValue.SelectedIndex = ddlNewValue.Items.IndexOf(ddlNewValue.Items.FindByValue(dt.Rows[0]["NewValue"].ToString()));

                    txtEditNewValue.Visible = false;

                    ddlNewValue.Visible = true;
                }
                else if (Fieldname == "Shift")
                {
                    Attendance.BAL.EmployeeBL obj = new Attendance.BAL.EmployeeBL();
                    DataTable ds = obj.GetShifts();
                    DataView dv = ds.DefaultView;
                    dv.RowFilter = "locationID=" + Convert.ToInt32(dt.Rows[0]["locationID"].ToString());
                    DataTable dt1 = dv.ToTable();

                    ddlNewValue.DataSource = dt1;
                    ddlNewValue.DataTextField = "ShiftName";
                    ddlNewValue.DataValueField = "ShiftID";
                    ddlNewValue.DataBind();

                    ddlNewValue.SelectedIndex = ddlNewValue.Items.IndexOf(ddlNewValue.Items.FindByValue(dt.Rows[0]["NewValue"].ToString()));
                    txtEditNewValue.Visible = false;
                    ddlNewValue.Visible = true;
                }
                else if (Fieldname == "Filling status")
                {
                    ddlNewValue.DataSource = null;
                    ddlNewValue.DataBind();
                    ddlNewValue.Items.Insert(0, new ListItem("Single", "1"));
                    ddlNewValue.Items.Insert(1, new ListItem("Married", "2"));

                    txtEditNewValue.Visible = false;
                    ddlNewValue.Visible = true;
                    ddlNewValue.SelectedIndex = ddlNewValue.Items.IndexOf(ddlNewValue.Items.FindByValue(dt.Rows[0]["NewValue"].ToString()));
                }
                else
                {
                    txtEditNewValue.Text = dt.Rows[0]["NewValue"].ToString();
                    txtEditNewValue.Visible = true;
                    ddlNewValue.Visible = false;
                }
            }
            catch (Exception ex)
            {
            }
        }
Пример #9
0
        protected void btnLeaveReqSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                Business obj = new Business();
                int userid = Convert.ToInt32(Session["UserID"]);
                DateTime FromDate = Convert.ToDateTime(txtLeaveFrom.Text);
                DateTime ToDate = Convert.ToDateTime(txtLeaveTo.Text);
                string Reason = txtReason.Text == "" ? "" : GeneralFunction.ToProperNotes(txtReason.Text);

                string timezone = "";
                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";

                }
                DateTime ISTTime = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));
                DataSet ds = obj.SaveLeaveRequestDetails(userid, "", FromDate, ToDate, ISTTime, Reason, "");
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables[0].Rows.Count > 0)
                    {
                        if (ds.Tables[0].Rows[0]["LeaveID"].ToString() == "Applied")
                        {
                            lblLeaveError.Text = "You have already applied leave for these days";
                            lblLeaveError.Visible = true;
                            txtReason.Text = "";
                            txtLeaveFrom.Text = "";
                            txtLeaveTo.Text = "";
                        }
                        else
                        {
                            System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('Leave request updated successfully');", true);
                            mdlNewLeaveRequest.Hide();

                            DateTime startDate = Convert.ToDateTime(Session["TodayDate"]);
                            DateTime endDate = startDate.AddDays(7);

                            EmployeeBL objLeave = new EmployeeBL();
                            DataTable datas = objLeave.GetLeaveRequestDetByUserID(Convert.ToInt32(Session["UserID"]), startDate, endDate);
                            grdSingleLeaveReq.DataSource = datas;
                            grdSingleLeaveReq.DataBind();
                            objLeave = null;
                        }
                    }
                }

            }
            catch (Exception ex)
            {
            }
        }
Пример #10
0
        private void GetCalender(DateTime MonthStart, DateTime MonthEnd, int locationID)
        {
            EmployeeBL obj = new EmployeeBL();
            DataTable dtAttandence = new DataTable();
            try
            {
                DataTable dt = obj.GetHolidayDetByLoc(MonthStart, MonthEnd, locationID,0,0);
                Session["HolidayMgmt"] = dt;
                dtAttandence.Columns.Add("Sunday", typeof(string));
                dtAttandence.Columns.Add("Monday", typeof(string));
                dtAttandence.Columns.Add("Tuesday", typeof(string));
                dtAttandence.Columns.Add("Wednesday", typeof(string));
                dtAttandence.Columns.Add("Thursday", typeof(string));
                dtAttandence.Columns.Add("Friday", typeof(string));
                dtAttandence.Columns.Add("Saturday", typeof(string));

                DateTime current = Convert.ToDateTime("01/01/1900");
                bool first = true;
                DayOfWeek GetDay = Convert.ToDateTime(MonthStart).DayOfWeek;
                int days = 1;

                for (int j = 0; j < 7; j++)
                {
                    dtAttandence.Rows.Add();
                    if (first)
                    {
                        first = false;
                        switch (GetDay)
                        {
                            case DayOfWeek.Sunday:
                                current = MonthStart;
                                dtAttandence.Rows[j]["Sunday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Monday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Tuesday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Wednesday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Thursday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Friday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Saturday"] = current;
                                days++;
                                break;
                            case DayOfWeek.Monday:
                                current = MonthStart;
                                dtAttandence.Rows[j]["Monday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Tuesday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Wednesday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Thursday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Friday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Saturday"] = current;
                                days++;
                                break;
                            case DayOfWeek.Tuesday:
                                current = MonthStart;
                                dtAttandence.Rows[j]["Tuesday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Wednesday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Thursday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Friday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Saturday"] = current;
                                days++;
                                break; // TODO: might not be correct. Was : Exit Select
                            case DayOfWeek.Wednesday:
                                current = MonthStart;
                                dtAttandence.Rows[j]["Wednesday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Thursday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Friday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Saturday"] = current;
                                days++;
                                break;
                            case DayOfWeek.Thursday:
                                current = MonthStart;
                                dtAttandence.Rows[j]["Thursday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Friday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Saturday"] = current;
                                days++;
                                break;
                            case DayOfWeek.Friday:
                                current = MonthStart;
                                dtAttandence.Rows[j]["Friday"] = current;
                                days++;
                                current = current.AddDays(1);
                                dtAttandence.Rows[j]["Saturday"] = current;
                                days++;
                                break;
                            case DayOfWeek.Saturday:
                                current = MonthStart;
                                dtAttandence.Rows[j]["Saturday"] = current;
                                days++;
                                break;
                        }

                    }
                    else
                    {
                        if (days <= Convert.ToInt32(MonthEnd.ToString("dd")))
                        {
                            current = current.AddDays(1);
                            dtAttandence.Rows[j]["Sunday"] = current;
                            days++;
                        }
                        if (days <= Convert.ToInt32(MonthEnd.ToString("dd")))
                        {
                            current = current.AddDays(1);
                            dtAttandence.Rows[j]["Monday"] = current;
                            days++;
                        }
                        if (days <= Convert.ToInt32(MonthEnd.ToString("dd")))
                        {
                            current = current.AddDays(1);
                            dtAttandence.Rows[j]["Tuesday"] = current;
                            days++;
                        }
                        if (days <= Convert.ToInt32(MonthEnd.ToString("dd")))
                        {
                            current = current.AddDays(1);
                            dtAttandence.Rows[j]["Wednesday"] = current;
                            days++;
                        }
                        if (days <= Convert.ToInt32(MonthEnd.ToString("dd")))
                        {
                            current = current.AddDays(1);
                            dtAttandence.Rows[j]["Thursday"] = current;
                            days++;
                        }
                        if (days <= Convert.ToInt32(MonthEnd.ToString("dd")))
                        {
                            current = current.AddDays(1);
                            dtAttandence.Rows[j]["Friday"] = current;
                            days++;
                        }
                        if (days <= Convert.ToInt32(MonthEnd.ToString("dd")))
                        {
                            current = current.AddDays(1);
                            dtAttandence.Rows[j]["Saturday"] = current;
                            days++;
                        }

                        if (days >= Convert.ToInt32(MonthEnd.ToString("dd")))
                        {
                            j = 6;
                        }
                    }
                }
                DataTable dsMonth = GetMonthlyRepByuserID(MonthStart, MonthEnd, Convert.ToInt32(Session["userID"]));
                Session["MonthRep"] = dsMonth;
                grdMonthlyRep.DataSource = dtAttandence;
                grdMonthlyRep.DataBind();

            }
            catch (Exception ex)
            {
            }
        }
Пример #11
0
        private DataTable GetReportIndia1(DateTime StartDate, DateTime EndTime, int LocationID, int shiftID)
        {
            DataTable dtPayroll = new DataTable();
            dtPayroll.Columns.Add("empid", typeof(string));
            dtPayroll.Columns.Add("Empname", typeof(string));
            dtPayroll.Columns.Add("PEmpname", typeof(string));
            dtPayroll.Columns.Add("Termdate", typeof(DateTime));
            dtPayroll.Columns.Add("Startdate", typeof(DateTime));
            dtPayroll.Columns.Add("DeptName", typeof(string));
            dtPayroll.Columns.Add("LocationName", typeof(string));
            dtPayroll.Columns.Add("MasterEmpType", typeof(string));
            dtPayroll.Columns.Add("LocDescriptiom", typeof(string));

            dtPayroll.Columns.Add("userid", typeof(string));
            dtPayroll.Columns.Add("Workingdays", typeof(int));
            dtPayroll.Columns.Add("Present", typeof(double));
            dtPayroll.Columns.Add("paidLeaves", typeof(int));
            dtPayroll.Columns.Add("Leaves", typeof(int));
            dtPayroll.Columns.Add("Holidays", typeof(int));
            dtPayroll.Columns.Add("LeavesAvailable", typeof(int));
            dtPayroll.Columns.Add("PaidLeaveStartDt", typeof(DateTime));
            dtPayroll.Columns.Add("PaidLeavesBalanced", typeof(int));
            dtPayroll.Columns.Add("PaidLeavesUsed", typeof(int));
            dtPayroll.Columns.Add("CalLeaves", typeof(int));
            dtPayroll.Columns.Add("Salary", typeof(double));
            dtPayroll.Columns.Add("Noshow", typeof(int));

            dtPayroll.Columns.Add("CalSalary", typeof(double));
            dtPayroll.Columns.Add("Bonus", typeof(double));
            dtPayroll.Columns.Add("Incentives", typeof(double));
            dtPayroll.Columns.Add("PrevUnpaid", typeof(double));
            dtPayroll.Columns.Add("AdvancePaid", typeof(double));
            dtPayroll.Columns.Add("Expenses", typeof(double));
            dtPayroll.Columns.Add("LoanDeduct", typeof(double));
            dtPayroll.Columns.Add("TotalPay", typeof(double));
            try
            {

                DataSet ds = new DataSet();
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["AttendanceConn"].ToString());
                SqlCommand cmd = new SqlCommand();
                SqlDataAdapter da = new SqlDataAdapter("[USP_FnAdmin]", con);
                da.SelectCommand.Parameters.Add(new SqlParameter("@shiftID", shiftID));
                da.SelectCommand.Parameters.Add(new SqlParameter("@LocationID", LocationID));
                da.SelectCommand.Parameters.Add(new SqlParameter("@startdate", StartDate));
                da.SelectCommand.Parameters.Add(new SqlParameter("@EndDate", EndTime));

                da.SelectCommand.CommandType = CommandType.StoredProcedure;
                da.Fill(ds);
                EmployeeBL obj = new EmployeeBL();

                // DataTable dtPaid = GetPayrollDataByLoc(LocationID, StartDate.AddMonths(-1), StartDate.AddSeconds(-1));
                DataTable dtPaid1 = obj.Usp_GetEmployeePayrollDataByLocation(LocationID, StartDate, EndTime,Convert.ToInt32(ddlShift.SelectedValue));
                DataTable dtPaid = obj.GetEmpPaidleavesDetailsByLocation(LocationID, StartDate.AddMonths(-1), StartDate.AddSeconds(-1),Convert.ToInt32(ddlShift.SelectedValue));
                int days = (Convert.ToInt32(EndTime.ToString("dd")) - Convert.ToInt32(StartDate.ToString("dd"))) + 1;
                if (ds.Tables.Count > 0)
                {
                    if (ds.Tables.Count > 1)
                    {
                        for (int j = 0; j < ds.Tables[0].Rows.Count; j++)
                        {
                            dtPayroll.Rows.Add();
                            if (dtPaid1.Rows.Count > 0)
                            {

                                DataView dvP = dtPaid1.DefaultView;
                                DataTable dtPaidLev = new DataTable();
                                dvP.RowFilter = "empid='" + ds.Tables[0].Rows[j]["empid"].ToString() + "'";
                                dtPaidLev = dvP.ToTable();
                                dtPayroll.Rows[j]["userid"] = ds.Tables[0].Rows[j]["userid"].ToString();
                                dtPayroll.Rows[j]["empid"] = ds.Tables[0].Rows[j]["empid"].ToString();
                                dtPayroll.Rows[j]["Empname"] = ds.Tables[0].Rows[j]["firstName"].ToString() + " " + ds.Tables[0].Rows[j]["lastname"].ToString();
                                dtPayroll.Rows[j]["PEmpname"] = ds.Tables[0].Rows[j]["PfirstName"].ToString() + " " + ds.Tables[0].Rows[j]["Plastname"].ToString();
                                dtPayroll.Rows[j]["Termdate"] = ds.Tables[0].Rows[j]["Termdate"].ToString() == "NULL" ? Convert.ToDateTime("01/01/1900") : ds.Tables[0].Rows[j]["Termdate"].ToString() == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(Convert.ToDateTime(ds.Tables[0].Rows[j]["Termdate"]).ToString("MM/dd/yyyy"));
                                dtPayroll.Rows[j]["Startdate"] = ds.Tables[0].Rows[j]["Startdate"].ToString() == "NULL" ? Convert.ToDateTime("01/01/1900") : ds.Tables[0].Rows[j]["Startdate"].ToString() == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(Convert.ToDateTime(ds.Tables[0].Rows[j]["Startdate"]).ToString("MM/dd/yyyy"));
                                dtPayroll.Rows[j]["DeptName"] = ds.Tables[0].Rows[j]["DeptName"].ToString() == "NULL" ? "" : ds.Tables[0].Rows[j]["DeptName"].ToString();
                                dtPayroll.Rows[j]["LocationName"] = ds.Tables[0].Rows[j]["LocationName"].ToString() == "NULL" ? "" : ds.Tables[0].Rows[j]["LocationName"].ToString();
                                dtPayroll.Rows[j]["MasterEmpType"] = ds.Tables[0].Rows[j]["EmpType"].ToString() == "NULL" ? "" : ds.Tables[0].Rows[j]["EmpType"].ToString();
                                dtPayroll.Rows[j]["LocDescriptiom"] = ds.Tables[0].Rows[j]["LocDescriptiom"].ToString() == "NULL" ? "" : ds.Tables[0].Rows[j]["LocDescriptiom"].ToString();
                                dtPayroll.Rows[j]["Salary"] = ds.Tables[0].Rows[j]["Salary"].ToString() == "" ? 0.0 : ds.Tables[0].Rows[j]["Salary"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(ds.Tables[0].Rows[j]["Salary"].ToString());
                                dtPayroll.Rows[j]["Workingdays"] = dtPaidLev.Rows[0]["WkngDays"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["WkngDays"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["WkngDays"].ToString());
                                dtPayroll.Rows[j]["Present"] = dtPaidLev.Rows[0]["Atndays"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["Atndays"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["Atndays"].ToString());
                                dtPayroll.Rows[j]["Leaves"] = dtPaidLev.Rows[0]["Leaves"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["Leaves"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["Leaves"].ToString());
                                dtPayroll.Rows[j]["Noshow"] = dtPaidLev.Rows[0]["Noshow"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["Noshow"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["Noshow"].ToString());
                                dtPayroll.Rows[j]["LeavesAvailable"] = dtPaidLev.Rows[0]["PaidLeaves"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["PaidLeaves"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["PaidLeaves"].ToString());
                                dtPayroll.Rows[j]["PaidLeavesUsed"] = dtPaidLev.Rows[0]["PaidLeavesUsed"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["PaidLeavesUsed"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["PaidLeavesUsed"].ToString());
                                dtPayroll.Rows[j]["PaidLeavesBalanced"] = dtPaidLev.Rows[0]["PaidLeavesBalanced"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["PaidLeavesBalanced"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["PaidLeavesBalanced"].ToString());
                                dtPayroll.Rows[j]["CalLeaves"] = dtPaidLev.Rows[0]["TotalCalLeaves"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["TotalCalLeaves"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["TotalCalLeaves"].ToString());
                                dtPayroll.Rows[j]["CalSalary"] = dtPaidLev.Rows[0]["CalSalary"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["CalSalary"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["CalSalary"].ToString());
                                dtPayroll.Rows[j]["Bonus"] = dtPaidLev.Rows[0]["Bonus"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["Bonus"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["Bonus"].ToString());
                                dtPayroll.Rows[j]["Incentives"] = dtPaidLev.Rows[0]["Incentives"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["Incentives"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["Incentives"].ToString());
                                dtPayroll.Rows[j]["PrevUnpaid"] = dtPaidLev.Rows[0]["PrevUnpaid"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["PrevUnpaid"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["PrevUnpaid"].ToString());
                                dtPayroll.Rows[j]["AdvancePaid"] = dtPaidLev.Rows[0]["Advancepaid"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["Advancepaid"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["Advancepaid"].ToString());
                                dtPayroll.Rows[j]["Expenses"] = dtPaidLev.Rows[0]["ExpensesRecieved"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["ExpensesRecieved"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["ExpensesRecieved"].ToString());
                                dtPayroll.Rows[j]["LoanDeduct"] = dtPaidLev.Rows[0]["LoanDeduct"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["LoanDeduct"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["LoanDeduct"].ToString());
                                dtPayroll.Rows[j]["TotalPay"] = dtPaidLev.Rows[0]["TotalPay"].ToString() == "" ? 0.0 : dtPaidLev.Rows[0]["TotalPay"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(dtPaidLev.Rows[0]["TotalPay"].ToString());
                            }
                            else
                            {
                                DataTable dt = ds.Tables[1];
                                DataView dv = dt.DefaultView;
                                DataTable dtname = new DataTable();
                                DateTime NextDate = GeneralFunction.GetNextDayOfWeekDate(StartDate);

                                DataTable dtL = ds.Tables[2];
                                DataView dvL = dtL.DefaultView;
                                DataTable dtLeave = new DataTable();

                                DataTable dtH = ds.Tables[3];
                                DataView dvH = dtH.DefaultView;
                                DataTable dtHoliday = new DataTable();

                                DataView dvP = dtPaid.DefaultView;
                                DataTable dtPaidLev = new DataTable();

                                dv.RowFilter = "empid='" + ds.Tables[0].Rows[j]["empid"].ToString() + "'";
                                dtname = dv.ToTable();

                                dvL.RowFilter = "empid='" + ds.Tables[0].Rows[j]["empid"].ToString() + "'";
                                dtLeave = dvL.ToTable();

                                dvH.RowFilter = "empid='" + ds.Tables[0].Rows[j]["empid"].ToString() + "'";
                                dtHoliday = dvH.ToTable();

                                dvP.RowFilter = "empid='" + ds.Tables[0].Rows[j]["empid"].ToString() + "'";
                                dtPaidLev = dvP.ToTable();

                                int holidays = 0;
                                int leaves = 0;
                                double present = 0.0;
                                int noshow = 0;
                                dtPayroll.Rows[j]["userid"] = ds.Tables[0].Rows[j]["userid"].ToString();
                                dtPayroll.Rows[j]["empid"] = ds.Tables[0].Rows[j]["empid"].ToString();
                                dtPayroll.Rows[j]["Empname"] = ds.Tables[0].Rows[j]["firstName"].ToString() + " " + ds.Tables[0].Rows[j]["lastname"].ToString();
                                dtPayroll.Rows[j]["PEmpname"] = ds.Tables[0].Rows[j]["PfirstName"].ToString() + " " + ds.Tables[0].Rows[j]["Plastname"].ToString();
                                dtPayroll.Rows[j]["Termdate"] = ds.Tables[0].Rows[j]["Termdate"].ToString() == "NULL" ? Convert.ToDateTime("01/01/1900") : ds.Tables[0].Rows[j]["Termdate"].ToString() == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(Convert.ToDateTime(ds.Tables[0].Rows[j]["Termdate"]).ToString("MM/dd/yyyy"));
                                dtPayroll.Rows[j]["Startdate"] = ds.Tables[0].Rows[j]["Startdate"].ToString() == "NULL" ? Convert.ToDateTime("01/01/1900") : ds.Tables[0].Rows[j]["Startdate"].ToString() == "" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(Convert.ToDateTime(ds.Tables[0].Rows[j]["Startdate"]).ToString("MM/dd/yyyy"));
                                dtPayroll.Rows[j]["DeptName"] = ds.Tables[0].Rows[j]["DeptName"].ToString() == "NULL" ? "" : ds.Tables[0].Rows[j]["DeptName"].ToString();
                                dtPayroll.Rows[j]["LocationName"] = ds.Tables[0].Rows[j]["LocationName"].ToString() == "NULL" ? "" : ds.Tables[0].Rows[j]["LocationName"].ToString();
                                dtPayroll.Rows[j]["MasterEmpType"] = ds.Tables[0].Rows[j]["EmpType"].ToString() == "NULL" ? "" : ds.Tables[0].Rows[j]["EmpType"].ToString();
                                dtPayroll.Rows[j]["LocDescriptiom"] = ds.Tables[0].Rows[j]["LocDescriptiom"].ToString() == "NULL" ? "" : ds.Tables[0].Rows[j]["LocDescriptiom"].ToString();
                                dtPayroll.Rows[j]["Salary"] = ds.Tables[0].Rows[j]["Salary"].ToString() == "" ? 0.0 : ds.Tables[0].Rows[j]["Salary"].ToString() == "NULL" ? 0.0 : Convert.ToDouble(ds.Tables[0].Rows[j]["Salary"].ToString());
                                dtPayroll.Rows[j]["LeavesAvailable"] = 0;
                                if (dtPaidLev.Rows.Count > 0)
                                {
                                    if (dtPaidLev.Rows[0]["PaidLeavesStartDt"].ToString()!="NULL" && dtPaidLev.Rows[0]["PaidLeavesStartDt"].ToString() != "" && Convert.ToDateTime(dtPaidLev.Rows[0]["PaidLeavesStartDt"]).ToString("MM/dd/yyyy") != "01/01/1900")
                                    {
                                        if (Convert.ToDateTime(dtPaidLev.Rows[0]["PaidLeavesStartDt"].ToString()) <= StartDate.AddSeconds(-1))
                                        {
                                            int PaidLeaves = dtPaidLev.Rows[0]["PaidLeavesBalanced"].ToString() == "" ? 0 : dtPaidLev.Rows[0]["PaidLeavesBalanced"].ToString() == "NULL" ? 0 : Convert.ToInt32(dtPaidLev.Rows[0]["PaidLeavesBalanced"].ToString());
                                            dtPayroll.Rows[j]["LeavesAvailable"] = PaidLeaves + (dtPaidLev.Rows[0]["MonthlyEligible"].ToString() == "" ? 0 : dtPaidLev.Rows[0]["MonthlyEligible"].ToString() == "NULL" ? 0 : Convert.ToInt32(dtPaidLev.Rows[0]["MonthlyEligible"].ToString()));
                                            dtPayroll.Rows[j]["PaidLeaveStartDt"] = dtPaidLev.Rows[0]["PaidLeavesStartDt"].ToString() == "" ? Convert.ToDateTime("01/01/1900") : dtPaidLev.Rows[0]["PaidLeavesStartDt"].ToString() == "NULL" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(dtPaidLev.Rows[0]["PaidLeavesStartDt"].ToString());
                                        }
                                        else
                                        {
                                            dtPayroll.Rows[j]["LeavesAvailable"] = "0";
                                        }
                                    }
                                    else
                                    {
                                        dtPayroll.Rows[j]["LeavesAvailable"] = "0";
                                    }
                                }
                                else
                                {
                                    if (ds.Tables[0].Rows[j]["PaidLeavesStartDt"].ToString() != "NULL" && ds.Tables[0].Rows[j]["PaidLeavesStartDt"].ToString() != "" && Convert.ToDateTime(ds.Tables[0].Rows[j]["PaidLeavesStartDt"]).ToString("MM/dd/yyyy") != "01/01/1900")
                                    {
                                        if (Convert.ToDateTime(ds.Tables[0].Rows[j]["PaidLeavesStartDt"].ToString()) <= StartDate.AddSeconds(-1))
                                        {
                                            int PaidLeaves = 0;
                                            dtPayroll.Rows[j]["LeavesAvailable"] = PaidLeaves + (ds.Tables[0].Rows[j]["MonthlyEligible"].ToString() == "" ? 0 : ds.Tables[0].Rows[j]["MonthlyEligible"].ToString() == "NULL" ? 0 : Convert.ToInt32(ds.Tables[0].Rows[j]["MonthlyEligible"].ToString()));
                                            dtPayroll.Rows[j]["PaidLeaveStartDt"] = ds.Tables[0].Rows[j]["PaidLeavesStartDt"].ToString() == "" ? Convert.ToDateTime("01/01/1900") : ds.Tables[0].Rows[j]["PaidLeavesStartDt"].ToString() == "NULL" ? Convert.ToDateTime("01/01/1900") : Convert.ToDateTime(ds.Tables[0].Rows[j]["PaidLeavesStartDt"].ToString());
                                        }
                                        else
                                        {
                                            dtPayroll.Rows[j]["LeavesAvailable"] = "0";
                                        }
                                    }
                                    else
                                    {
                                        dtPayroll.Rows[j]["LeavesAvailable"] = "0";
                                    }
                                }
                                if (dtname.Rows.Count > 0)
                                {
                                    DateTime startDate = StartDate;
                                    DateTime nextdate = NextDate;

                                    for (int i = 0; i < days; i++)
                                    {
                                        DataView dv1 = dtname.DefaultView;
                                        dv1.RowFilter = "Logindate >= #" + startDate + "# and Logindate<#" + nextdate + "#";
                                        DataTable dt1 = dv1.ToTable();

                                        DataView dL = dtLeave.DefaultView;
                                        dL.RowFilter = "Fromdate<=#" + startDate + "# and #" + startDate + "#<=Todate";
                                        DataTable dtLvResult = dL.ToTable();

                                        DataView dH = dtHoliday.DefaultView;
                                        dH.RowFilter = "HolidayDate >= #" + startDate + "# and HolidayDate<#" + nextdate + "#";
                                        DataTable dtHolResult = dH.ToTable();
                                        if (dtHolResult.Rows.Count > 0)
                                        {
                                            holidays += 1;
                                        }
                                        if (dt1.Rows.Count > 0)
                                        {
                                            double dayhrs = 0.0;
                                            for (int k = 0; k < dt1.Rows.Count; k++)
                                            {
                                                if (dt1.Rows[k]["logoutdate"].ToString().Trim() != "")
                                                {
                                                    if (dt1.Rows[k]["total hours worked"].ToString() == "")
                                                    {
                                                        dayhrs += 0.0;
                                                    }
                                                    else
                                                    {
                                                        dayhrs += Convert.ToDouble(dt1.Rows[k]["total hours worked"].ToString());
                                                    }
                                                }
                                                else
                                                {
                                                    noshow += 1;
                                                }
                                            }
                                            if (dayhrs > 5)
                                            {
                                                present += 1;
                                            }
                                            else if (dayhrs > 3 && dayhrs < 5)
                                            {
                                                present += 0.5;
                                            }
                                            else if (dayhrs > 0.0 && dayhrs < 3)
                                            {
                                                leaves += 1;
                                            }
                                        }
                                        else if (dtHolResult.Rows.Count <= 0 && dtLvResult.Rows.Count > 0)
                                        {
                                            leaves += 1;
                                        }
                                        else if (dtHolResult.Rows.Count <= 0 && dtLvResult.Rows.Count <= 0 && dt1.Rows.Count <= 0)
                                        {
                                            noshow += 1;
                                        }
                                        else
                                        {
                                            noshow += 1;
                                        }
                                        dL.RowFilter = null;
                                        dH.RowFilter = null;
                                        dv1.RowFilter = null;
                                        startDate = nextdate;
                                        nextdate = GeneralFunction.GetNextDayOfWeekDate(nextdate);
                                    }
                                }
                                if (dtHoliday.Rows.Count > 0)
                                {
                                    DateTime startDate = StartDate;
                                    DateTime nextdate = NextDate;
                                    for (int i = 0; i < days; i++)
                                    {
                                        DataView dH = dtHoliday.DefaultView;
                                        dH.RowFilter = "HolidayDate >= #" + startDate + "# and HolidayDate<#" + nextdate + "#";
                                        DataTable dtHolResult = dH.ToTable();
                                        DataView dL = dtLeave.DefaultView;
                                        dL.RowFilter = "Fromdate<=#" + startDate + "# and #" + startDate + "#<=Todate";
                                        DataTable dtLvResult = dL.ToTable();
                                        if (dtHolResult.Rows.Count > 0)
                                        {
                                            holidays += 1;
                                        }
                                        else if (dtLvResult.Rows.Count > 0)
                                        {
                                            leaves += 1;
                                        }
                                        else
                                        {
                                            noshow += 1;
                                        }
                                        dL.RowFilter = null;
                                        dH.RowFilter = null;
                                        startDate = nextdate;
                                        nextdate = GeneralFunction.GetNextDayOfWeekDate(nextdate);
                                    }
                                }
                                dtPayroll.Rows[j]["Present"] = present;
                                dtPayroll.Rows[j]["Workingdays"] = days - holidays;
                                dtPayroll.Rows[j]["Leaves"] = leaves;
                                dtPayroll.Rows[j]["Holidays"] = holidays;
                                if (Convert.ToInt32(dtPayroll.Rows[j]["LeavesAvailable"]) > Convert.ToInt32(dtPayroll.Rows[j]["leaves"]))
                                {
                                    dtPayroll.Rows[j]["PaidLeavesBalanced"] = Convert.ToInt32(dtPayroll.Rows[j]["LeavesAvailable"]) - Convert.ToInt32(dtPayroll.Rows[j]["leaves"]);
                                    dtPayroll.Rows[j]["PaidLeavesUsed"] = Convert.ToInt32(dtPayroll.Rows[j]["LeavesAvailable"]) - Convert.ToInt32(dtPayroll.Rows[j]["PaidLeavesBalanced"]);
                                    dtPayroll.Rows[j]["CalLeaves"] = 0;
                                }
                                else if (Convert.ToInt32(dtPayroll.Rows[j]["leaves"]) > Convert.ToInt32(dtPayroll.Rows[j]["LeavesAvailable"]))
                                {
                                    dtPayroll.Rows[j]["CalLeaves"] = Convert.ToInt32(dtPayroll.Rows[j]["leaves"]) - Convert.ToInt32(dtPayroll.Rows[j]["LeavesAvailable"]);
                                    dtPayroll.Rows[j]["PaidLeavesUsed"] = Convert.ToInt32(dtPayroll.Rows[j]["leaves"]) - Convert.ToInt32(dtPayroll.Rows[j]["CalLeaves"]);
                                    dtPayroll.Rows[j]["PaidLeavesBalanced"] = 0;
                                }
                                else
                                {
                                    dtPayroll.Rows[j]["PaidLeavesBalanced"] = Convert.ToInt32(dtPayroll.Rows[j]["LeavesAvailable"]) - Convert.ToInt32(dtPayroll.Rows[j]["leaves"]);
                                    dtPayroll.Rows[j]["PaidLeavesUsed"] = Convert.ToInt32(dtPayroll.Rows[j]["LeavesAvailable"]) - Convert.ToInt32(dtPayroll.Rows[j]["PaidLeavesBalanced"]);
                                    dtPayroll.Rows[j]["CalLeaves"] = Convert.ToInt32(dtPayroll.Rows[j]["LeavesAvailable"]) - Convert.ToInt32(dtPayroll.Rows[j]["leaves"]);
                                }
                                //salary calculation  CalSalary  CalLeaves
                                double CurntSalary = Convert.ToDouble(dtPayroll.Rows[j]["Salary"]);
                                int wrkDays = Convert.ToInt32(dtPayroll.Rows[j]["Workingdays"]);
                                double CalSalary = 0.0;
                                if (Convert.ToInt32(dtPayroll.Rows[j]["Present"]) > 0)
                                {
                                    double perdaySal = wrkDays == 0 ? 0 : Math.Round(CurntSalary / Convert.ToDouble(wrkDays));
                                    double paiddaysOff = perdaySal * (dtPayroll.Rows[j]["PaidLeavesUsed"].ToString() == "" ? 0 : dtPayroll.Rows[j]["PaidLeavesUsed"].ToString() == "NULL" ? 0 : Convert.ToInt32(dtPayroll.Rows[j]["PaidLeavesUsed"]));
                                    double ActualSalary = perdaySal * Convert.ToInt32(dtPayroll.Rows[j]["Present"]);
                                    CalSalary = paiddaysOff + ActualSalary;
                                    dtPayroll.Rows[j]["CalSalary"] = CalSalary;
                                    dtPayroll.Rows[j]["TotalPay"] = CalSalary;
                                }
                                else
                                {
                                    dtPayroll.Rows[j]["CalSalary"] = 0.0;
                                    dtPayroll.Rows[j]["TotalPay"] = 0.0;
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
            }
            return dtPayroll;
        }
 private void GetDeafualtHolidays(int shiftID, int locationID, int departmentID)
 {
     try
     {
         EmployeeBL objemp = new EmployeeBL();
         DataTable dt = objemp.GetDefaultHolidays(shiftID, locationID, departmentID);
         if (dt.Rows.Count > 0)
         {
             rptDefaultHoliday.DataSource = dt;
             rptDefaultHoliday.DataBind();
             lblDefLoc1.Text = ddlLocation.SelectedItem.Text;
             lblDefShift1.Text = ddlShift.SelectedItem.Text;
             lblNoDefault.Text = "";
             divNodefault.Style["display"] = "none";
         }
         else
         {
             lblDefLoc1.Text = ddlLocation.SelectedItem.Text;
             lblDefShift1.Text = ddlShift.SelectedItem.Text;
             lblNoDefault.Text = "No default holidays found";
             divNodefault.Style["display"] = "block";
             rptDefaultHoliday.DataSource = null;
             rptDefaultHoliday.DataBind();
         }
     }
     catch (Exception ex)
     {
     }
 }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string DefaultDay = ddlDay.SelectedItem.Text;
                int fromYr = Convert.ToInt32(ddlFromYear.SelectedItem.Text.ToString().Trim());
                int toYr = Convert.ToInt32(ddlToYear.SelectedItem.Text.ToString().Trim());
                int LocationID = Convert.ToInt32(ddlDefaultlocation.SelectedItem.Value);
                string shiftName = ddlDefaultShift.SelectedItem.Value;

                DateTime startDate = new DateTime(fromYr, 1, 1);
                DateTime endDate = new DateTime(toYr, 12, 31);
                int EnterBy = Convert.ToInt32(Session["UserID"]);

                string timezone = "";
                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";

                }
                DateTime Enterdate = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));
                String strHostName = Request.UserHostAddress.ToString();
                string IpAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

                //TimeSpan diff = endDate - startDate;
                //int days = diff.Days;
                EmployeeBL obj = new EmployeeBL();
                //for (var i = 0; i <= days; i++)
                //{
                //    var testDate = startDate.AddDays(i);
                //    if (testDate.DayOfWeek.ToString() == DefaultDay)
                //    {
                //        bool bnew = obj.SaveandGetHolidayDet(true, testDate, LocationID, 0, shiftName, EnterBy, Enterdate, IpAddress, "Default", true);
                //    }
                //}
                bool bnew = obj.SaveDefaultHolidayDet(startDate, endDate, true, LocationID, 0, shiftName, EnterBy, Enterdate, IpAddress, DefaultDay, true, DefaultDay);
                mdlAddDefault.Hide();
                System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('Default holidays updated successfully..');", true);
                EmployeeBL objemp = new EmployeeBL();
                GetDeafualtHolidays(Convert.ToInt32(ddlShift.SelectedValue), Convert.ToInt32(ddlLocation.SelectedItem.Value), Convert.ToInt32(ddlDepartment.SelectedValue));

                DateTime Start = Convert.ToDateTime(Session["MonthHolStart"]);
                DateTime EndDt = Convert.ToDateTime(Session["MonthHolEnd"]);
                int shiftID = Convert.ToInt32(ddlShift.SelectedValue);
                int Location = Convert.ToInt32(ddlLocation.SelectedItem.Value);
                int departmentID = Convert.ToInt32(ddlDepartment.SelectedValue);
                GetCalender(Start, EndDt, Location, shiftID, departmentID);

                mdlDefaultmgmt.Show();
            }
            catch (Exception ex)
            {
            }
        }
        protected void btnSaveDefault_Click(object sender, EventArgs e)
        {
            EmployeeBL obj = new EmployeeBL();
            try
            {
                int LocationID=Convert.ToInt32(ddlLocation.SelectedValue);
                int deptID=0;
                string shiftName=ddlShift.SelectedItem.Text;
                int EnterBy = Convert.ToInt32(Session["UserID"]);

                string timezone = "";
                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";
                }
                DateTime Enterdate = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));
                String strHostName = Request.UserHostAddress.ToString();
                string IpAddress = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

                for (int i = 0; i<rptDefaultHoliday.Items.Count; i++)
                {
                    CheckBox chkDefaultDay = (CheckBox)rptDefaultHoliday.Items[i].FindControl("chkDefaultDay");
                    if (!chkDefaultDay.Checked)
                    {
                        int fromYr =Convert.ToInt32(chkDefaultDay.Attributes["FromYr"]);
                        int toyr = Convert.ToInt32(chkDefaultDay.Attributes["ToYr"]);
                        DateTime startDate = new DateTime(fromYr, 1, 1);
                        DateTime endDate = new DateTime(toyr, 12, 31);

                        obj.UpdateDefaultHolidayDet(startDate,endDate,false, chkDefaultDay.Text.Trim(), LocationID, deptID, shiftName, EnterBy, Enterdate, IpAddress);
                    }
                }

                GetDeafualtHolidays(Convert.ToInt32(ddlShift.SelectedValue), LocationID, deptID);
                DateTime Start = Convert.ToDateTime(Session["MonthHolStart"]);
                DateTime EndDt = Convert.ToDateTime(Session["MonthHolEnd"]);
                int shiftID = Convert.ToInt32(ddlShift.SelectedValue);
                int departmentID = Convert.ToInt32(ddlDepartment.SelectedValue);
                GetCalender(Start, EndDt, LocationID, shiftID, departmentID);

            }
            catch (Exception ex)
            {

            }
        }
        private void GetEffectiveChangeStatus()
        {
            try
            {
                EmployeeBL obj = new EmployeeBL();
                DataTable dt = obj.GetEffectiveChangeStatus();
                ddlSelect.DataSource = dt;
                ddlSelect.DataTextField = "ChangeStatus";
                ddlSelect.DataValueField = "ChangeStatusID";
                ddlSelect.DataBind();
                ddlSelect.Items.Insert(0, new ListItem("ALL", "0"));

                ddlEditStatus.DataSource = dt;
                ddlEditStatus.DataTextField = "ChangeStatus";
                ddlEditStatus.DataValueField = "ChangeStatusID";
                ddlEditStatus.DataBind();
                ddlEditStatus.Items.Insert(0, new ListItem("Select", "0"));
            }
            catch (Exception ex)
            {
            }
        }
Пример #16
0
        protected void ddlReportType_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                int userid = Convert.ToInt32(Session["UserID"]);
                EmployeeBL obj = new EmployeeBL();
                if (ddlReportType.SelectedValue == "1")
                {

                    DateTime monthStart = Convert.ToDateTime(ViewState["MonthSatrt"]);
                    DateTime monthEnd = monthStart.AddMonths(1).AddSeconds(-1);

                    GetCalender(monthStart, monthEnd, 1);

                    grdSingleLeaveReq.DataSource = null;
                    grdSingleLeaveReq.DataBind();
                    dvSingle.Style["display"] = "none";
                    dvMonthrep.Style["display"] = "block";

                    if (monthStart.ToString("MM/dd/yyyy") == Convert.ToDateTime(ViewState["CurrentMonth"]).ToString("MM/dd/yyyy"))
                    {
                        btnNext.CssClass = "btn btn-danger btn-small disabled";
                        btnNext.Enabled = false;
                    }
                    else
                    {
                        btnNext.CssClass = "btn btn-danger btn-small enabled";
                        btnNext.Enabled = true;
                    }
                }
                else
                {

                    DateTime TodayDate = Convert.ToDateTime(Session["TodayDate"]);
                    if (GeneralFunction.GetFirstDayOfWeekDate(TodayDate).ToString("MM/dd/yyyy") == GeneralFunction.GetFirstDayOfWeekDate(DateTime.Now).ToString("MM/dd/yyyy"))
                    {
                        btnNext.CssClass = "btn btn-danger btn-small disabled";
                        btnNext.Enabled = false;
                    }
                    else
                    {
                        btnNext.CssClass = "btn btn-danger btn-small enabled";
                        btnNext.Enabled = true;
                    }

                    DateTime Start = GeneralFunction.GetFirstDayOfWeekDate(TodayDate);
                    DateTime End = GeneralFunction.GetLastDayOfWeekDate(TodayDate);
                    DataTable ds = new DataTable();
                    ds = GetReportSingle(Start, End, userid);

                    Session["AtnDetails"] = ds;
                    if (ds.Rows.Count > 0)
                    {
                        grdAttendanceSingle.DataSource = ds;
                        grdAttendanceSingle.DataBind();
                        dvSingle.Style["display"] = "block";
                        dvMonthrep.Style["display"] = "none";
                        grdSingleLeaveReq.DataSource = null;
                        grdSingleLeaveReq.DataBind();

                    }

                }

            }
            catch (Exception ex)
            {

            }
        }
 private void GetEffectiveData(int LocationID, int shiftID, DateTime StartDt, DateTime EndDt,int stausID)
 {
     try
     {
         EmployeeBL obj = new EmployeeBL();
         DataTable dt = obj.GetEffectivedataByLocation(LocationID, StartDt, EndDt, shiftID,stausID);
         lblMonthRep.Text = "(" + StartDt.ToString("MM/dd/yyyy") + " - " + EndDt.ToString("MM/dd/yyyy") + ")";
         if (dt.Rows.Count > 0)
         {
             grdUsers.DataSource = dt;
             grdUsers.DataBind();
             lblNodata.Text = "";
             dvNodata.Style["display"] = "none";
         }
         else
         {
             grdUsers.DataSource = null;
             grdUsers.DataBind();
             lblNodata.Text = "No data found";
             dvNodata.Style["display"] = "block";
         }
     }
     catch (Exception ex)
     {
     }
 }
Пример #18
0
        protected void lnkLeaveReq_Click(object sender, EventArgs e)
        {
            try
            {
                EmployeeBL obj = new EmployeeBL();

                if (ddlReportType.SelectedValue.ToString() == "0")
                {
                    DateTime startDate = Convert.ToDateTime(Session["TodayDate"]);
                    DateTime endDate = startDate.AddDays(7);
                    DataTable ds = obj.GetLeaveRequestDetByUserID(Convert.ToInt32(Session["UserID"]), startDate, endDate);
                    grdSingleLeaveReq.DataSource = ds;
                    grdSingleLeaveReq.DataBind();
                }
                else
                {
                    DateTime startDate = Convert.ToDateTime(ViewState["MonthSatrt"]);
                    DateTime endDate = startDate.AddMonths(1).AddSeconds(-1);
                    DataTable ds = obj.GetLeaveRequestDetByUserID(Convert.ToInt32(Session["UserID"]), startDate, endDate);
                    grdSingleLeaveReq.DataSource = ds;
                    grdSingleLeaveReq.DataBind();
                }

            }
            catch (Exception ex)
            {
            }
        }
Пример #19
0
        protected void btnResetPassword_Click(object sender, EventArgs e)
        {
            try
            {
                string password = txtResetNewPassword.Text.Trim();
                string EmpID = lblEmpID.Text.Trim();
                String strHostName = Request.UserHostAddress.ToString();
                int userid = Convert.ToInt32(Session["UserID"]);
                string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
                string timezone = "";


                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";

                }
                DateTime ISTTime = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));

                var CurentDatetime = ISTTime;


                EmployeeBL obj = new EmployeeBL();
                bool bnew = obj.ResetPassWordByAdmin(userid, strIp, password, CurentDatetime, EmpID);
                mdlResetPassword.Hide();


            }
            catch (Exception ex)
            {

            }

        }
Пример #20
0
        private void CreateNewEmployeeList(int EmpID)
        {
            try
            {
                Attendance.BAL.EmployeeBL obj = new EmployeeBL();
                DataTable dt = obj.GetEmployyeDetailsByUserID(EmpID);
                dtNewEmp.Merge(dt);
            }
            catch (Exception ex)
            {

            }
        }
        protected void btnSchUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string SchStartTime = txtSheduleStart.Text.ToString().Trim();
                string SchEndTime = txtScheduleEnd.Text.ToString().Trim();
                string LunchStartime = txtLunchStart.Text.ToString().Trim();
                string LunchEndtime = txtLunchEnd.Text.ToString().Trim();
                bool Fivedays = false;
                 bool Sixdays = false;
                 bool Sevendays = false;
                if (rdFive.Checked)
                {
                    Fivedays = true;
                }
                else if (rdSix.Checked)
                {
                    Sixdays = true;
                }
                else if (rdSeven.Checked)
                {
                    Sevendays = true;
                }

                int UserID = Convert.ToInt32(Session["UserID"]);

                string timezone = "";
                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";

                }
                DateTime ISTTime = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));

                String strHostName = Request.UserHostAddress.ToString();
                string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();

                EmployeeBL obj = new EmployeeBL();
                string ID = obj.AddNewSchedule(SchStartTime, SchEndTime, LunchStartime, LunchEndtime, Fivedays, Sixdays, Sevendays, strIp, ISTTime, UserID);
                mdlSchedulepopup.Hide();
                GetSchedules();
                ddlSchedule.SelectedIndex =ddlSchedule.Items.IndexOf(ddlSchedule.Items.FindByValue(ID==""?"0":ID));
                mdlAddPopUp.Show();
                
            }
            catch (Exception ex)
            {
            }
      
        }
        protected void grdUsers_RowUpdating(object sender, GridViewUpdateEventArgs e)
        {
            try
            {
                EmployeeBL obj = new EmployeeBL();
                int PaidLeaveID = 0;
                if (grdUsers.DataKeys[e.RowIndex].Value.ToString().Trim()!= "")
                {
                     PaidLeaveID = Convert.ToInt32(grdUsers.DataKeys[e.RowIndex].Value);
                }
                HiddenField hdnUserid = (HiddenField)grdUsers.Rows[e.RowIndex].FindControl("hdnUserid");
                int PaidLeaveUserID = Convert.ToInt32(hdnUserid.Value);
                TextBox txtLeavesStartDt = (TextBox)grdUsers.Rows[e.RowIndex].FindControl("txtLeavesStartDt");
                TextBox txtLevAvail = (TextBox)grdUsers.Rows[e.RowIndex].FindControl("txtLeavAvailable");
                TextBox txtLeavesUsed = (TextBox)grdUsers.Rows[e.RowIndex].FindControl("txtLeavesUsed");
                TextBox txtLeavBalanced = (TextBox)grdUsers.Rows[e.RowIndex].FindControl("txtLeavBalanced");
                //TextBox txtMAxLevAvail = (TextBox)grdUsers.Rows[e.RowIndex].FindControl("txtMaxEligible");
                TextBox txtNotes = (TextBox)grdUsers.Rows[e.RowIndex].FindControl("txtNotes");
                string timezone = "";
                if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                {
                    timezone = "Eastern Standard Time";
                }
                else
                {
                    timezone = "India Standard Time";
                }

                DateTime StartDate = Convert.ToDateTime(ViewState["PaidStartDate"]);
                DateTime CurrentDate = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));
                int LeaveAvail =txtLevAvail.Text==""?0:Convert.ToInt32(txtLevAvail.Text);
               // int MaxLeaveAvail = Convert.ToInt32(txtMAxLevAvail.Text);
                int LeavesUsed =txtLeavesUsed.Text==""?0:Convert.ToInt32(txtLeavesUsed.Text);
                int LeavesBalanced =txtLeavBalanced.Text==""?0:Convert.ToInt32(txtLeavBalanced.Text);
                DateTime LeavesStartDt =txtLeavesStartDt.Text==""?Convert.ToDateTime("01/01/1900"): Convert.ToDateTime(txtLeavesStartDt.Text);
                string notes = txtNotes.Text.Trim() == "" ? "" : GeneralFunction.ToProperNotes(txtNotes.Text) + "<br>" + "-------------------------------------<br>" +
                               "Updated by " + Session["EmpName"].ToString().Trim() + " at " + CurrentDate + "<br>" + "***********************************" + "<br>";
                int userid = Convert.ToInt32(Session["UserID"]);
                String strHostName = Request.UserHostAddress.ToString();
                string strIp = System.Net.Dns.GetHostAddresses(strHostName).GetValue(0).ToString();
                bool bnew = obj.UpdatePaidLeaveByLeaveID(LeaveAvail, LeavesUsed, LeavesBalanced, PaidLeaveID, userid, notes, StartDate, LeavesStartDt, strIp, PaidLeaveUserID, CurrentDate);
                grdUsers.EditIndex = -1;

                DateTime EndDate = Convert.ToDateTime(ViewState["PaidEndDate"]);
                GetpaidLeavesData(Convert.ToInt32(ddlLocation.SelectedItem.Value), StartDate, EndDate, Convert.ToInt32(ddlShift.SelectedValue));
            }
            catch (Exception ex)
            {
            }
        }
        protected void btnUpdatePassCode_Click(object sender, EventArgs e)
        {
            try
            {
                //string location = ddlLocation.SelectedItem.Text.ToString().Trim();
                string EmpName = Session["EmpName"].ToString().Trim();
                int userid = Convert.ToInt32(Session["UserID"]);
                string oldPasscode = txtOldpasscode.Text.Trim();
                string NewPasscode = txtNewPasscode.Text.Trim();

                Attendance.BAL.EmployeeBL obj = new EmployeeBL();
                bool bnew = obj.UpdatePasscodeByUserID(userid, oldPasscode, NewPasscode);
                if (bnew)
                {
                    txtOldpasscode.Text = "";
                    txtNewPasscode.Text = "";
                    txtConfirmPasscode.Text = "";
                    mdlChangePasscode.Hide();
                    System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "Script", "alert('Passcode changed successfully..');", true);
                }

            }
            catch (Exception ex)
            {
            }
        }
 private void GetpaidLeavesData(int locationID, DateTime startDt, DateTime EndDt,int shiftID)
 {
     try
     {
         EmployeeBL obj = new EmployeeBL();
         DataTable dt = obj.GetEmpPaidleavesDetailsByLocation(locationID,startDt,EndDt,shiftID);
         lblLeaveReport.Text = "(" + startDt.ToString("MM/dd/yyyy") + "-" + EndDt.ToString("MM/dd/yyyy") + ")";
         if (dt.Rows.Count > 0)
         {
             grdUsers.DataSource = dt;
             Session["AllPaidLeavesData"] = dt;
             grdUsers.DataBind();
             lblTotal.Visible = true;
             lblTotal.Text = "Total Employee(s) :" + dt.Rows.Count;
             lblNodata.Visible = false;
             dvlblNodata.Style["display"] = "none";
         }
         else
         {
             lblNodata.Visible = true;
             dvlblNodata.Style["display"] = "block";
             lblNodata.Text = "No data found";
             lblTotal.Text = "";
             grdUsers.DataSource = null;
             grdUsers.DataBind();
         }
     }
     catch (Exception ex)
     {
     }
 }
        protected void btnLeeaveApproveUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                string Records = hdnChkRecords.Value.ToString();
                if (Records.Trim().Length > 0)
                {
                    string[] recordID = Records.Split(',');
                    for (int i = 0; i < recordID.Length-1; i++)
                    {
                    string timezone = "";
                    if (Convert.ToInt32(Session["TimeZoneID"]) == 2)
                    {
                        timezone = "Eastern Standard Time";
                    }
                    else
                    {
                        timezone = "India Standard Time";
                    }
                    DateTime ISTTime = TimeZoneInfo.ConvertTime(DateTime.UtcNow, TimeZoneInfo.FindSystemTimeZoneById(timezone));
                    int LeaveID = Convert.ToInt32(recordID[i]);
                    string notes = txtLeaveNotes.Text.Trim() == "" ? "" : GeneralFunction.ToProperNotes(txtLeaveNotes.Text) + "<br>" + " <br>" +
                                  ddlLeaveApprove.SelectedItem.Text+" by " + Session["EmpName"].ToString().Trim() + " at " + ISTTime + "<br>" + "------------------------------------<br>";
                    int ApprovedStatusID = Convert.ToInt32(ddlLeaveApprove.SelectedValue);
                    int ApprovedBy = Convert.ToInt32(Session["UserID"]);
                    EmployeeBL obj = new EmployeeBL();
                    bool bnew = obj.UpdateLeaveRequest(LeaveID, ApprovedBy, ApprovedStatusID, notes, ISTTime);
                   }

                }
                mdlLeaveStatusUpdate.Hide();
                int StatusID = Convert.ToInt32(ddlSelect.SelectedValue);
                GetLeavesDetails(ddlGrdLocation.SelectedItem.Text.ToString().Trim(), Convert.ToDateTime(ViewState["StartMonth"]), Convert.ToDateTime(ViewState["EndMonth"]), StatusID, Convert.ToInt32(ddlShift.SelectedValue));
            }
            catch (Exception ex)
            {
            }
        }
 private void GetdepartmentsByshiftLoc(string shiftname, int locationID)
 {
     try
     {
         EmployeeBL obj = new EmployeeBL();
         DataTable dt = obj.GetDepartmentByShifts(shiftname, locationID);
         ddlPopDept.DataSource = dt;
         ddlPopDept.DataTextField = "Deptname";
         ddlPopDept.DataValueField = "DeptID";
         ddlPopDept.DataBind();
         ddlPopDept.Items.Insert(0, new ListItem("Select", "Select"));
         ddlPopDept.Items.Insert(1, new ListItem("ALL", "0"));
     }
     catch (Exception ex)
     {
     }
 }