Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        private void LoadWorkingCalendarByEmployee()
        {
            monthCalendar1.Dates.Clear();
            int DeparmentID = (int)departmentTreeView.SelectedNode.Tag;
            dsEmployee = employeeDO.GetEmployeeByDepartment(DeparmentID);
            int employeeID = (int)dsEmployee.Tables[0].Rows[selectedRowIndex]["EmployeeID"];
            workingTimeDO = new RegWorkingTimeDO();
            dsWorkingTime = workingTimeDO.GetOverTimeByMonth(employeeID, CurrentMonth, CurrentYear);
            shiftDO = new ShiftDO();
            DataSet dsShiftOver = new DataSet();
            if (dsWorkingTime.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow dr in dsWorkingTime.Tables[0].Rows)
                {
                    DateTime Day = DateTime.Parse(dr["WorkingDay"].ToString());
                    int ShiftOverID = int.Parse(dr["ShiftOverID"].ToString());
                    dsShiftOver = shiftDO.GetShiftOverByID(ShiftOverID);

                    DateItem dateItem = new DateItem();
                    dateItem.DateColor = lblOverTimeLegend.ForeColor;
                    dateItem.BackColor = lblOverTimeLegend.BackColor;
                    dateItem.Date = Day;
                    if (dsShiftOver != null)
                        dateItem.Text = dsShiftOver.Tables[0].Rows[0]["ShiftName"].ToString();
                    monthCalendar1.AddDateInfo(dateItem);

                }
            }
            monthCalendar1.Refresh();
            monthCalendar1.ClearSelection();
        }
Пример #2
0
        /// <summary>
        /// Đăng ký làm thêm giờ 
        /// </summary>
        public void RegDepartmentOverTime(DateTime workingDay)
        {
            frmMessage frmMessage = new frmMessage();
            string OverTimeMessage = "";
            int STT = 0;

            for (int i = 0; i < lvwListEmployee.SelectedIndicies.Length; i++)
            {
                // chỉ số hàng được chọn
                int rowIndex = (int)lvwListEmployee.SelectedItems[i].Tag;
                DataRow drEmployee = dsEmployee.Tables[0].Rows[rowIndex];
                //				dr.BeginEdit();

                //			foreach (DataRow drEmployee in dsEmployee.Tables[0].Rows)
                //			{
                int ret = 0;
                try
                {
                    DataRow dr = dsRegOverTime.Tables[0].NewRow();
                    //					dr.BeginEdit();

                    dr.BeginEdit();
                    dr["EmployeeID"] = drEmployee["EmployeeID"];
                    ShiftDO shiftDO = new ShiftDO();
                    DataSet dsShiftOver = shiftDO.GetShiftOverByID(int.Parse(cboShift.SelectedValue.ToString()));
                    dr["ShiftOverID"] = dsShiftOver.Tables[0].Rows[0]["ShiftOverID"].ToString();

                    dr["StartOverTime"] = dsShiftOver.Tables[0].Rows[0]["TimeIn"].ToString();
                    DateTime startTime = Convert.ToDateTime(dsShiftOver.Tables[0].Rows[0]["TimeIn"].ToString());
                    DateTime stopTime = Convert.ToDateTime(dsShiftOver.Tables[0].Rows[0]["TimeOut"].ToString());
                    DateTime startLunch = Convert.ToDateTime(dsShiftOver.Tables[0].Rows[0]["LunchStart"].ToString());
                    DateTime stopLunch = Convert.ToDateTime(dsShiftOver.Tables[0].Rows[0]["LunchStop"].ToString());
                    DateTime startDinner = Convert.ToDateTime(dsShiftOver.Tables[0].Rows[0]["DinnerStart"].ToString());
                    DateTime stopDinner = Convert.ToDateTime(dsShiftOver.Tables[0].Rows[0]["DinnerStop"].ToString());
                    TimeSpan leng = stopTime - startTime - (stopLunch - startLunch) - (stopDinner - startDinner);
                    DateTime length = Convert.ToDateTime("12/12/2005 " + leng.Hours + ":" + leng.Minutes + ":" + leng.Milliseconds);

                    dr["Length"] = Convert.ToDateTime(length).ToShortTimeString();
                    //Convert.ToDateTime(stopTime - startTime - (stopLunch - startLunch) - (stopDinner - startDinner))
                    //    .ToShortTimeString();
                    dr["WorkingDay"] = workingDay.ToShortDateString();
                    dr["WorkOverTimeInfo"] = txtWorkOverTimeInfo.Text;
                    if (ckHaveDinner.Checked)
                    {
                        dr["DinnerAmount"] = Double.Parse(cboDinnnerAmount.Text);
                    }
                    else
                    {
                        dr["DinnerAmount"] = DBNull.Value;
                    }
                    dr.EndEdit();
                    dsRegOverTime.Tables[0].Rows.Add(dr);

                    ret = regOverTimeDO.AddRegOverTime(dsRegOverTime);
                }
                catch
                {
                }
                if (ret == EmployeeStatus.EMPLOYEE_LEAVE)
                {
                    OverTimeMessage = drEmployee["CardID"] + " - " + drEmployee["EmployeeName"] + " đã đi công tác";
                    STT++;
                    frmMessage.AddMessage(STT.ToString() + ". " + OverTimeMessage);
                }

                if (ret == EmployeeStatus.EMPLOYEE_REST)
                {
                    OverTimeMessage = drEmployee["CardID"] + " - " + drEmployee["EmployeeName"] + " đã đăng ký nghỉ";
                    STT++;
                    frmMessage.AddMessage(STT.ToString() + ". " + OverTimeMessage);
                }
                //else if (ret == EmployeeStatus.EMPLOYEE_ABSENT)
                //{

                //    OverTimeMessage = drEmployee["CardID"] + " - " + drEmployee["EmployeeName"] + " vắng mặt";
                //    STT++;
                //    frmMessage.AddMessage(STT.ToString() + ". " + OverTimeMessage);
                //}
            }
            if (STT != 0)
            {
                frmMessage.Show();
            }
            else
            {
                frmMessage.Close();
                string str = WorkingContext.LangManager.GetString("frmRegOverTime1_DangKyOT_Messa1");
                string str1 = WorkingContext.LangManager.GetString("frmRegOverTime1_DangKyOT_Title");
                //MessageBox.Show("Không thể đăng ký làm thêm giờ cho nhân viên này", "Đăng ký làm thêm giờ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                MessageBox.Show(str, str1, MessageBoxButtons.OK, MessageBoxIcon.Information);
                //				if ((this.Text =="Thêm đăng ký làm thêm giờ" )|| (this.Text == "Sửa đăng ký làm thêm giờ"))
                //				{
                //					MessageBox.Show("Đăng ký làm thêm giờ cho bộ phận " + departmentTreeView.SelectedNode.Text + " thành công!", "Đăng ký làm thêm giờ", MessageBoxButtons.OK, MessageBoxIcon.Information);
                //				}
                //				else
                //				{
                //					MessageBox.Show(departmentTreeView.SelectedNode.Text +" の部門の残業登録が正常に完了しました !","",MessageBoxButtons.OK, MessageBoxIcon.Information);
                //
                //				}
            }
        }