Пример #1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            TBL_MP_HR_HolidaysAndWeekOff model    = null;
            ServiceHolidayAndWeekOffs    _service = new ServiceHolidayAndWeekOffs();

            try
            {
                if (!this.ValidateChildren())
                {
                    return;
                }

                if (this.HolidayID == 0)
                {
                    model = new TBL_MP_HR_HolidaysAndWeekOff();
                }
                else
                {
                    model = _service.GetHolidayDbRecordByHolidayID(this.HolidayID);
                }

                model.FK_YearID = ((SelectListItem)cboFinancialYear.SelectedItem).ID;
                if (radioBtnHoliday.Checked)
                {
                    model.HolidayType = (int)ATTENDANCE_TYPE.HOLIDAY;
                }
                if (radioBtnWeekOff.Checked)
                {
                    model.HolidayType = (int)ATTENDANCE_TYPE.WEEK_OFF;
                }
                model.HolidayDate = dtDate.Value;
                model.Remarks     = txtRemark.Text.Trim();

                if (this.HolidayID == 0)
                {
                    this.HolidayID = _service.AddNewHolidayAndWeekOffs(model);
                }
                else
                {
                    _service.UpdateHolidayAndWeekOffsInfo(model);
                }


                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "frmAddEditHolidayAndWeekOff::btnOK_Click", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        public void PopulateHolidayAndWeekOffViews()
        {
            btnDeleteHoliday.Visible = true;
            ServiceHolidayAndWeekOffs _service = new ServiceHolidayAndWeekOffs();

            try
            {
                tbl_Acct_Financial_Year model = (new ServiceMASTERS()).GetFinancialYearDbRecordByID(this.SelectedFYID);
                if (model != null)
                {
                    this.SuspendLayout();
                    monthViewControl = new ComponentFactory.Krypton.Toolkit.KryptonMonthCalendar();
                    //monthViewControl.MaxDate = DateTime.Now;
                    //monthViewControl.MinDate = DateTime.Now;
                    monthViewControl.MinDate      = (DateTime)model.FromDate;
                    monthViewControl.MaxDate      = (DateTime)model.ToDate;
                    monthViewControl.DateChanged += _Calender_DateChanged;
                    //_Calender.DayStyle = ButtonStyle.Standalone;
                    //_Calender.OverrideBolded.Day.Back.Color1 = System.Drawing.Color.Red;
                    //_Calender.HeaderStyle = HeaderStyle.Primary;
                    monthViewControl.SelectionStart    = (DateTime)model.FromDate;
                    monthViewControl.SelectionEnd      = (DateTime)model.FromDate;
                    monthViewControl.MaxSelectionCount = 1;
                    monthViewControl.ShowToday         = false;
                    monthViewControl.ShowTodayCircle   = false;


                    List <TBL_MP_HR_HolidaysAndWeekOff> lstHolidays = _service.GetAllHolidaysForTheFinYear(this.SelectedFYID);
                    _HolidayAndWeekOffList = new BindingList <SelectListItem>();
                    foreach (TBL_MP_HR_HolidaysAndWeekOff item in lstHolidays)
                    {
                        monthViewControl.AddBoldedDate(item.HolidayDate);
                        _HolidayAndWeekOffList.Add(new SelectListItem()
                        {
                            ID = item.PK_HolidayID, Code = item.HolidayDate.ToString("dd MMM yyyy"), Description = item.Remarks
                        });
                    }
                    gridHolidaysAndWeekOffs.DataSource = _HolidayAndWeekOffList;
                    //make these columns hidden PK_HolidayID, FK_YearID, HolidayType
                    gridHolidaysAndWeekOffs.Columns["ID"].Visible =
                        gridHolidaysAndWeekOffs.Columns["DescriptionToUpper"].Visible =
                            gridHolidaysAndWeekOffs.Columns["IsActive"].Visible       = false;

                    this.monthViewControl.CalendarDimensions = new System.Drawing.Size(4, 3);
                    this.monthViewControl.DayOfWeekStyle     = ComponentFactory.Krypton.Toolkit.ButtonStyle.Alternate;
                    this.monthViewControl.DayStyle           = ComponentFactory.Krypton.Toolkit.ButtonStyle.Standalone;
                    this.monthViewControl.Dock     = System.Windows.Forms.DockStyle.Fill;
                    this.monthViewControl.Location = new System.Drawing.Point(0, 0);
                    this.monthViewControl.OverrideBolded.Day.Back.Color1     = System.Drawing.Color.Yellow;
                    this.monthViewControl.OverrideBolded.Day.Back.Color2     = System.Drawing.Color.Red;
                    this.monthViewControl.OverrideBolded.Day.Back.ColorStyle = ComponentFactory.Krypton.Toolkit.PaletteColorStyle.Solid;
                    //this._Calender.OverrideBolded.Day.Border.Color1 = System.Drawing.Color.Lime;
                    //this._Calender.OverrideBolded.Day.Border.ColorStyle = ComponentFactory.Krypton.Toolkit.PaletteColorStyle.Solid;
                    //this._Calender.OverrideBolded.Day.Border.DrawBorders = ((ComponentFactory.Krypton.Toolkit.PaletteDrawBorders)((((ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Top | ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Bottom)
                    //| ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Left)
                    //| ComponentFactory.Krypton.Toolkit.PaletteDrawBorders.Right)));
                    //this._Calender.OverrideBolded.Day.Border.Width = 1;
                    this.monthViewControl.OverrideBolded.Day.Content.ShortText.Color1 = System.Drawing.Color.Red;
                    this.monthViewControl.OverrideBolded.Day.Content.LongText.Color2  = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(64)))), ((int)(((byte)(0)))));
                    this.monthViewControl.OverrideBolded.Day.Content.ShortText.Font   = new System.Drawing.Font("Microsoft Sans Serif", 10.2F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                    this.monthViewControl.OverrideBolded.Day.Content.ShortText.TextH  = ComponentFactory.Krypton.Toolkit.PaletteRelativeAlign.Center;
                    this.monthViewControl.OverrideBolded.Day.Content.ShortText.TextV  = ComponentFactory.Krypton.Toolkit.PaletteRelativeAlign.Center;

                    headerGroupCalendarView.Panel.Controls.Clear();
                    headerGroupCalendarView.Panel.Controls.Add(monthViewControl);
                    monthViewControl.Show();
                    this.ResumeLayout(false);
                    //monthViewControl.Dock = DockStyle.Fill;
                    headerGroupRight.ValuesPrimary.Heading     = string.Format("FA: {0}  till  {1}", model.FromDate.ToString("dd MMMM yyyy"), model.ToDate.ToString("dd MMMM yyyy "));
                    headerGroupRight.ValuesPrimary.Description = string.Format("Holidays: {0} Week-offs: {1}", _service.GetHolidayCountForYear(this.SelectedFYID), _service.GetWeekOffCountForYear(this.SelectedFYID));
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "PageHolidayAndWeekOffs::PopulateHolidayAndWeekOffViews", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        private void PrepareAttendanceDescription(KryptonHeaderGroup header, DateTime currDate)
        {
            string strDescription = string.Empty;
            int    employeeID     = 0;
            List <AttendanceColorModel> lstColors = (new ServiceEmployee()).GetAttendanceColorPreferencesOfEmployee(Program.CURR_USER.EmployeeID);

            try
            {
                header.HeaderStylePrimary = HeaderStyle.DockActive;
                string description = string.Empty;
                header.ValuesPrimary.Heading   = string.Format("{0} ({1})", currDate.ToString("dd MMM"), currDate.ToString("ddd"));
                header.ValuesPrimary.Image     = null;
                header.ValuesSecondary.Heading = string.Empty;
                List <vAttendanceRegister> dbItems = (new ServiceAttendance()).GetAttendanceInfoDbRecordsOfEmplyeeOnDate(this.EmployeeID, currDate);
                strDescription = string.Empty;
                foreach (vAttendanceRegister item in dbItems)
                {
                    strDescription += string.Format("{1}-{2} {0}", item.AttendanceRemarks, item.AttendInTime.ToString("hh:mmtt"), item.AttendOutTime.ToString("hh:mmtt"));
                    strDescription += (item.AtWarehouse) ? "At Warehouse ":"";
                    if (item.AttendanceType == (int)ATTENDANCE_TYPE.LEAVE || item.AttendanceType == (int)ATTENDANCE_TYPE.OUT_DOOR)
                    {
                        strDescription += string.Format("({0})\n\n", (item.IsActive)?"Approved":"Unapproved");
                        if (item.isLeaveRejected == true)
                        {
                            strDescription  = string.Empty;
                            strDescription += string.Format("{1}-{2} {0}", item.AttendanceRemarks, item.AttendInTime.ToString("hh:mmtt"), item.AttendOutTime.ToString("hh:mmtt"));
                            strDescription += (item.AtWarehouse) ? "At Warehouse " : "";
                            strDescription += string.Format("(Rejected)\n\n");
                        }
                    }
                }

                Label lblDescription = new Label();
                lblDescription.BackColor = Color.Transparent;
                lblDescription.Text      = strDescription;
                header.Panel.Controls.Add(lblDescription);
                lblDescription.Dock = DockStyle.Fill;
                if (dbItems.Count > 0)
                {
                    if (dbItems.Count == 1)
                    {
                        vAttendanceRegister dbItem         = dbItems[0];
                        ATTENDANCE_TYPE     attendanceTYPE = (ATTENDANCE_TYPE)dbItem.AttendanceType;

                        switch (attendanceTYPE)
                        {
                        case ATTENDANCE_TYPE.PRESENT:
                            header.ValuesPrimary.Description = "Present";
                            //header.ValuesSecondary.Heading = string.Format("{0} - {1}", dbItem.AttendInTime.ToString("hh:mm tt"), dbItem.AttendOutTime.ToString("hh:mm tt"));
                            //header.ValuesSecondary.Description = string.Format("{0}", dbItem.AttendanceRemarks);
                            header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.PRESENT).FirstOrDefault().ColorAttendance;
                            break;

                        case ATTENDANCE_TYPE.ABSENT:
                            header.ValuesPrimary.Description = "Absent";
                            //header.ValuesSecondary.Heading = string.Format("{0} - {1}", dbItem.AttendInTime.ToString("hh:mm tt"), dbItem.AttendOutTime.ToString("hh:mm tt"));
                            //header.ValuesSecondary.Description = string.Format("{0}", dbItem.AttendanceRemarks);
                            header.StateCommon.Back.Color1 = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.ABSENT).FirstOrDefault().ColorAttendance;
                            break;

                        case ATTENDANCE_TYPE.LEAVE:
                            header.ValuesPrimary.Description = "Leave";
                            header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.LEAVE).FirstOrDefault().ColorAttendance;
                            break;

                        case ATTENDANCE_TYPE.OUT_DOOR:
                            header.ValuesPrimary.Description = "Outdoor";
                            header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.OUT_DOOR).FirstOrDefault().ColorAttendance;
                            break;

                        case ATTENDANCE_TYPE.COMP_OFF:
                            header.ValuesPrimary.Description = "CompOff";
                            header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.COMP_OFF).FirstOrDefault().ColorAttendance;
                            break;

                        case ATTENDANCE_TYPE.LATE_COMING:
                            header.ValuesPrimary.Description = "Late Coming";
                            header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.LATE_COMING).FirstOrDefault().ColorAttendance;
                            break;

                        case ATTENDANCE_TYPE.EARLY_GOING:
                            header.ValuesPrimary.Description = "Early Leaving";
                            header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.EARLY_GOING).FirstOrDefault().ColorAttendance;
                            break;

                        case ATTENDANCE_TYPE.SANDWICH_LEAVE:
                            header.ValuesPrimary.Description = "Sandwich Leave";
                            header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.LEAVE).FirstOrDefault().ColorAttendance;
                            break;
                        }
                    }
                    else
                    {
                        header.ValuesPrimary.Description = "Multiple Entries";
                        header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.MULTIPLE).FirstOrDefault().ColorAttendance;
                    }
                }

                ServiceHolidayAndWeekOffs serviceOff = new ServiceHolidayAndWeekOffs();
                if (serviceOff.IsHolidayOrWeekOff(currDate))
                {
                    TBL_MP_HR_HolidaysAndWeekOff dbOff = serviceOff.GetHolidayDbRecordByDate(currDate);

                    if (dbOff != null)
                    {
                        if (dbOff.HolidayType == (int)ATTENDANCE_TYPE.WEEK_OFF)
                        {
                            if (AppCommon.isSecondSaturday(currDate) || AppCommon.isFourthSaturday(currDate))
                            {
                                if ((new ServiceEmployee()).IsWeekOffDayForEmployee("SATURDAY", this.EmployeeID))
                                {
                                    header.ValuesPrimary.Description = "Week Off";
                                    header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.WEEK_OFF).FirstOrDefault().ColorAttendance;
                                    strDescription     += string.Format("Week Off {0}", dbOff.Remarks);
                                    lblDescription.Text = strDescription;
                                }
                            }
                            else
                            {
                                header.ValuesPrimary.Description = "Week Off";
                                header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.WEEK_OFF).FirstOrDefault().ColorAttendance;
                                strDescription     += string.Format("Week Off {0}", dbOff.Remarks);
                                lblDescription.Text = strDescription;
                            }
                        }
                        if (dbOff.HolidayType == (int)ATTENDANCE_TYPE.HOLIDAY)
                        {
                            header.ValuesPrimary.Description = "Holiday";
                            header.StateCommon.Back.Color1   = lstColors.Where(x => x.TypeAttendance == ATTENDANCE_TYPE.HOLIDAY).FirstOrDefault().ColorAttendance;
                            strDescription     += string.Format("Holiday {0}", dbOff.Remarks);
                            lblDescription.Text = strDescription;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string errMessage = ex.Message;
                if (ex.InnerException != null)
                {
                    errMessage += string.Format("\n{0}", ex.InnerException.Message);
                }
                MessageBox.Show(errMessage, "ControlEmployeeAttendanceViewer::PrepareAttendanceDescription", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }