public ListColumnName(DateTime ThangNam, int ID_NhanVien) { DateTime start = new DateTime(ThangNam.Year, ThangNam.Month, 1); DateTime end = new DateTime(start.Year, start.Month, 1).AddMonths(1).AddDays(-1); lstColumnName = new Dictionary <string, List <double> >(); string HoVaTen = data.NHANSUs.Find(ID_NhanVien).HoVaTen; //item At Work - WFH List <double> tmpAtWork = new List <double>(); List <double> tmpWFH = new List <double>(); lstWorkingDaysForStaffOfMonth = data.fnDisplayWorkingDaysStaffOfMonth(HoVaTen, ThangNam).ToList(); for (int i = 0; i < lstWorkingDaysForStaffOfMonth.Count; i++) { tmpAtWork.Add((double)(Weekdays(start, end) - CalculateTotalOFFDayInWeekdays(lstWorkingDaysForStaffOfMonth[i].ID, start, end) - (lstWorkingDaysForStaffOfMonth[i].WFH.HasValue ? lstWorkingDaysForStaffOfMonth[i].WFH.Value : 0))); tmpWFH.Add((double)((lstWorkingDaysForStaffOfMonth[i].WFH.HasValue ? lstWorkingDaysForStaffOfMonth[i].WFH.Value : 0))); } lstColumnName.Add("At_Work", tmpAtWork); lstColumnName.Add("WFH", tmpWFH); //them toan bo PC vao list foreach (var item in data.PHUCAPs.ToList()) { List <fnGetAmountBenefit_Result> tmpBenefit = data.fnGetAmountBenefit(HoVaTen, start, item.ID, end).ToList(); List <double> tmpAmountBenefit = new List <double>(); foreach (var item1 in tmpBenefit) { tmpAmountBenefit.Add(Decimal.ToDouble((decimal)(item1.PC_CoDinh.HasValue ? item1.PC_CoDinh.Value : 0))); } lstColumnName.Add(item.TenPhuCap.Replace(" ", ""), tmpAmountBenefit); } }
public void LoadData() { if (this.searchBar.Text == "" || this.searchBar.Text == null) { lstWorkingDaysForStaffOfMonth = data.fnDisplayWorkingDaysStaffOfMonth("", MonthYear.Value).ToList(); } else { lstWorkingDaysForStaffOfMonth = data.fnDisplayWorkingDaysStaffOfMonth(this.searchBar.Text, MonthYear.Value).ToList(); } this.bunifuCustomDataGrid1.Rows.Clear(); Image img = Properties.Resources.icons8_edit_calendar_24; for (int i = 0; i < this.lstWorkingDaysForStaffOfMonth.Count; i++) { int Workingdays = Weekdays(new DateTime(this.MonthYear.Value.Year, this.MonthYear.Value.Month, 1), new DateTime(this.MonthYear.Value.Year, this.MonthYear.Value.Month, 1).AddMonths(1).AddDays(-1)); int PresentWorkingDays = (Workingdays - CalculateTotalOFFDayInWeekdays(this.lstWorkingDaysForStaffOfMonth[i].ID, new DateTime(this.MonthYear.Value.Year, this.MonthYear.Value.Month, 1), new DateTime(this.MonthYear.Value.Year, this.MonthYear.Value.Month, 1).AddMonths(1).AddDays(-1))); int WFH = this.lstWorkingDaysForStaffOfMonth[i].WFH.HasValue ? (int)this.lstWorkingDaysForStaffOfMonth[i].WFH.Value : 0; int Leaves = this.lstWorkingDaysForStaffOfMonth[i].LEAVES.HasValue ? (int)this.lstWorkingDaysForStaffOfMonth[i].LEAVES.Value : 0; this.bunifuCustomDataGrid1.Rows.Add(i + 1, this.lstWorkingDaysForStaffOfMonth[i].HoVaTen, Workingdays, PresentWorkingDays, WFH, PresentWorkingDays - WFH, Leaves ); } if (lstWorkingDaysForStaffOfMonth.Count == 0) { this.lbNoData.Show(); } else { this.lbNoData.Hide(); } }
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); } }
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); }