void Prepare_DienBienLuong() { try { DataTable dt = oTinhLuong.GetThongTinLuong_ByNV(ma_nv); if (dt.Rows.Count > 0) { dt_DienBienLuong = (from r in dt.AsEnumerable() orderby r.Field <DateTime>("tu_ngay") where r.Field <string>("khoan_or_heso") == "Hệ số" select r).CopyToDataTable(); // he so moi hien thi dt_DienBienLuong.Columns.Add("thang_nam", typeof(string)); dt_DienBienLuong.Columns.Add("ngach_bac", typeof(string)); for (int i = 0; i < dt_DienBienLuong.Rows.Count; i++) { dt_DienBienLuong.Rows[i]["thang_nam"] = Convert.ToDateTime(dt_DienBienLuong.Rows[i]["tu_ngay"]).Month + " / " + Convert.ToDateTime(dt_DienBienLuong.Rows[i]["tu_ngay"]).Year; dt_DienBienLuong.Rows[i]["ngach_bac"] = dt_DienBienLuong.Rows[i]["ten_ngach"] + " bậc " + dt_DienBienLuong.Rows[i]["bac"]; } } else // insert dong rỗng để show heading { dt_DienBienLuong.Columns.Add("thang_nam", typeof(string)); dt_DienBienLuong.Columns.Add("ngach_bac", typeof(string)); DataRow r = dt_DienBienLuong.NewRow(); r["thang_nam"] = " "; r["ngach_bac"] = " "; r["he_so"] = " "; } } catch (Exception) { } }
void GetThongTin_Luong(string ma_nv) { try { dtLuong = oTinhLuong.GetThongTinLuong_ByNV(ma_nv); int luong_id = (from n in dtLuong.AsEnumerable() where n.Field <int?>("ngach_bac_heso_id") != null select n.Field <int>("luong_id")).Max(); int bac_hs_id = (from l in dtLuong.AsEnumerable() where l.Field <int?>("luong_id") == luong_id select l.Field <int>("ngach_bac_heso_id") ).First(); DateTime tu_ngay = (from l in dtLuong.AsEnumerable() where l.Field <int?>("luong_id") == luong_id select l.Field <DateTime>("tu_ngay") ).First(); string ngach = (from n in dtBacHeSo.AsEnumerable() where n.Field <int>("id") == bac_hs_id select n.Field <string>("ten_ngach") + "-" + n.Field <string>("ma_ngach")).First(); int bac = (from n in dtBacHeSo.AsEnumerable() where n.Field <int>("id") == bac_hs_id select n.Field <int>("bac")).First(); double hs = (from n in dtBacHeSo.AsEnumerable() where n.Field <int>("id") == bac_hs_id select n.Field <double>("he_so")).First(); kvpNgachCu.Add(new KeyValuePair <string, string>(ma_nv, ngach)); kvpBacCu.Add(new KeyValuePair <string, int>(ma_nv, bac_hs_id)); kvpLuongID.Add(new KeyValuePair <string, int>(ma_nv, luong_id)); kvpHSCu.Add(new KeyValuePair <string, double>(ma_nv, hs)); kvpNgayHuongCu.Add(new KeyValuePair <string, DateTime>(ma_nv, tu_ngay)); kvpBacMoi.Add(new KeyValuePair <string, int>(ma_nv, bac_hs_id)); lstMaNV.Add(thongTinCNVC1.txt_MaNV.Text); lb_DSCNVC.Items.Add(thongTinCNVC1.txt_HoTen.Text); } catch (Exception) { MessageBox.Show("Không thể lấy thông tin ngạch bậc của nhân viên " + ma_nv + " , có thể do nhân viên này không có lương hệ số, xin vui lòng thử lại.", "Cảnh báo", MessageBoxButtons.OK, MessageBoxIcon.Error); } }