Exemple #1
0
        private void LoadData()
        {
            this.bunifuCustomDataGrid1.Rows.Clear();
            this.lbName.Text     = data.NHANSUs.Find(this.ID).HoVaTen;
            this.lbUserName.Text = data.NHANSUs.Find(this.ID).UserName;
            this.lbMonth.Text    = this.ThangNam.ToString("MM - yyyy");
            fnDisplayWorkingDaysStaffOfMonth_Result temp = data.fnDisplayWorkingDaysStaffOfMonth(this.lbName.Text, this.ThangNam).FirstOrDefault();

            if (temp != null)
            {
                this.lbWFH.Text        = (temp.WFH == null ? "0" : temp.LEAVES.ToString());
                this.lbLeaveHours.Text = (temp.LEAVES == null ? "0" : temp.LEAVES.ToString());
            }
            this.lbOFFDayTakeLeave.Text   = (CalcultDayOFFTakeLeave().ToString() == null ? "0" : CalcultDayOFFTakeLeave().ToString());
            this.lbDayOFFNoTakeLeave.Text = (CalculDayOFFNoTakeLeave().ToString() == null ? "0" : CalculDayOFFNoTakeLeave().ToString());
            this.lbTotalWorkingHours.Text = (((Weekdays(new DateTime(ThangNam.Year, ThangNam.Month, 1), new DateTime(ThangNam.Year, ThangNam.Month, 1).AddMonths(1).AddDays(-1))) * 8) - Convert.ToInt32(this.lbLeaveHours.Text)).ToString();
            try
            {
                this.TitleWorkingDay.DataSource    = data.LOAI_GIO_CONG.SqlQuery("SELECT * FROM LOAI_GIO_CONG").ToList();
                this.TitleWorkingDay.DisplayMember = "LoaiGioCong";
                this.TitleWorkingDay.ValueMember   = "ID";
                this.lstWorkingDayOfAEmployee      = data.fnDisplayInfoStaffWorkingDayInMonth(this.ID, this.ThangNam).ToList();
                int TotalWFH = 0;
                for (int i = 0; i < this.lstWorkingDayOfAEmployee.Count; i++)
                {
                    this.bunifuCustomDataGrid1.Rows.Add(i + 1,
                                                        this.lstWorkingDayOfAEmployee[i].ID_GioCong,
                                                        this.lstWorkingDayOfAEmployee[i].NgayGioBatDau.Value.ToString("dd/MM/yyyy [ HH:mm ]"),
                                                        this.lstWorkingDayOfAEmployee[i].NgayGioKetThuc.Value.ToString("dd/MM/yyyy [ HH:mm ]")
                                                        );
                }
                if (lstWorkingDayOfAEmployee.Count == 0)
                {
                    this.lbNoData.Show();
                }
                else
                {
                    this.lbNoData.Hide();
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemple #2
0
            public string convertStringFormula(string[] lstStringFormula)
            {
                string result = "";

                for (int i = 0; i < lstStringFormula.Length; i++)
                {
                    string str = lstStringFormula[i];
                    if (lstStringFormula[i].Contains("PC_"))
                    {
                        string[] parseElement = lstStringFormula[i].Split('_');
                        lstStringFormula[i] = ReplaceValue(lstStringFormula[i],
                                                           "PC_" + "\\d+",
                                                           data.spGetBenefit(ID_NhanVien, Int32.Parse(parseElement[1])).FirstOrDefault().Value.ToString("0.000"));
                    }
                    else if (lstStringFormula[i].Contains("BH_TH_"))
                    {
                        string[] parseElement = lstStringFormula[i].Split('_');
                        lstStringFormula[i] = ReplaceValue(lstStringFormula[i],
                                                           "BH_TH_" + "\\d+",
                                                           data.BAOHIEM_THUE.Find(Int32.Parse(parseElement[2].
                                                                                              Replace(")", "").
                                                                                              Replace("(", "").
                                                                                              Replace(",", ""))).PhanTramBaoHiem.ToString());
                    }
                    else if (lstStringFormula[i].Contains("NV_"))
                    {
                        string[] parseElement = lstStringFormula[i].Split('_');
                        switch (parseElement[1])
                        {
                        case "Km":
                        {
                            lstStringFormula[i] = lstStringFormula[i].Replace("NV_Km", data.NHANSUs.Find(this.ID_NhanVien).Km.HasValue ? data.NHANSUs.Find(this.ID_NhanVien).Km.Value.ToString() : "0");
                            break;
                        }

                        case "LuongCB":
                        {
                            lstStringFormula[i] = lstStringFormula[i].Replace("NV_LuongCB", data.NHANSUs.Find(this.ID_NhanVien).LuongCB.HasValue ? data.NHANSUs.Find(this.ID_NhanVien).LuongCB.Value.ToString() : "0");
                            break;
                        }

                        case "PayBack":
                        {
                            lstStringFormula[i] = lstStringFormula[i].Replace("NV_PayBack", data.NHANSUs.Find(this.ID_NhanVien).PayBack.HasValue ? data.NHANSUs.Find(this.ID_NhanVien).LuongCB.Value.ToString() : "0");
                            break;
                        }

                        case "NguoiPhuThuoc":
                        {
                            lstStringFormula[i] = lstStringFormula[i].Replace("NV_NguoiPhuThuoc", data.NHANSUs.Find(this.ID_NhanVien).SoNguoiPhuThuoc.HasValue ? data.NHANSUs.Find(this.ID_NhanVien).SoNguoiPhuThuoc.Value.ToString() : "0");
                            break;
                        }

                        default:
                        {
                            lstStringFormula[i] = "0";
                            break;
                        }
                        }
                    }
                    else if (lstStringFormula[i].Contains("OTH_"))
                    {
                        string[] parseElement = lstStringFormula[i].Split('_');
                        if (parseElement.Length < 0)
                        {
                            return(lstStringFormula[i]);
                        }
                        string[] resultFromFormulaPayrall = data.FORMULA_OF_PAYROLL.Find(Int32.Parse(parseElement[1]
                                                                                                     .Replace("(", "")
                                                                                                     .Replace(")", "")
                                                                                                     .Replace(",", "")
                                                                                                     )).Formula.Split(' ');
                        Calculate val = new Calculate();
                        lstStringFormula[i] = ReplaceValue(lstStringFormula[i],
                                                           "OTH_" + "\\d+",
                                                           val.CALCULATE(convertStringFormula(resultFromFormulaPayrall).Split(' '), ID_NhanVien, date).ToString());
                    }
                    else if (lstStringFormula[i].Contains("OT_"))
                    {
                        lstStringFormula[i] = "1";
                    }
                    else if (lstStringFormula[i].Contains("WorkingDays"))
                    {
                        lstStringFormula[i] = Weekdays(new DateTime(date.Year, date.Month, 1), new DateTime(date.Year, date.Month, 1).AddMonths(1).AddDays(-1)).ToString();
                    }
                    else if (lstStringFormula[i].Contains("AtWorks"))
                    {
                        int weekdays = Weekdays(new DateTime(date.Year, date.Month, 1), new DateTime(date.Year, date.Month, 1).AddMonths(1).AddDays(-1));
                        int OFFDays  = CalculateTotalOFFDayInWeekdays(ID_NhanVien,
                                                                      new DateTime(date.Year, date.Month, 1),
                                                                      new DateTime(date.Year, date.Month, 1).AddMonths(1).AddDays(-1));
                        string nameStaff = data.NHANSUs.Find(ID_NhanVien).HoVaTen;
                        fnDisplayWorkingDaysStaffOfMonth_Result WorkingHoursStaff = data.fnDisplayWorkingDaysStaffOfMonth(nameStaff, date).FirstOrDefault();
                        int WFHDays = WorkingHoursStaff.WFH.HasValue ? WorkingHoursStaff.WFH.Value : 0;
                        lstStringFormula[i] = (weekdays - OFFDays - WFHDays).ToString();
                    }
                    else if (lstStringFormula[i].Contains("WFHDays"))
                    {
                        string nameStaff = data.NHANSUs.Find(ID_NhanVien).HoVaTen;
                        fnDisplayWorkingDaysStaffOfMonth_Result WorkingHoursStaff = data.fnDisplayWorkingDaysStaffOfMonth(nameStaff, date).FirstOrDefault();
                        lstStringFormula[i] = WorkingHoursStaff.WFH.HasValue ? WorkingHoursStaff.WFH.Value.ToString() : "0";
                    }
                    else if (lstStringFormula[i].Contains("LeaveHours"))
                    {
                        string nameStaff = data.NHANSUs.Find(ID_NhanVien).HoVaTen;
                        fnDisplayWorkingDaysStaffOfMonth_Result WorkingHoursStaff = data.fnDisplayWorkingDaysStaffOfMonth(nameStaff, date).FirstOrDefault();
                        lstStringFormula[i] = WorkingHoursStaff.LEAVES.HasValue ? WorkingHoursStaff.LEAVES.Value.ToString() : "0";
                    }
                    else if (lstStringFormula[i].Contains("OFFDays"))
                    {
                        lstStringFormula[i] = CalculateTotalOFFDayInWeekdays(ID_NhanVien,
                                                                             new DateTime(date.Year, date.Month, 1),
                                                                             new DateTime(date.Year, date.Month, 1).AddMonths(1).AddDays(-1)).ToString();
                    }
                }
                foreach (string element in lstStringFormula)
                {
                    result += element;
                }
                return(result);
            }