Inheritance: IP.Core.IPUserService.US_Object
 //public DataRow get_luong_1_nhan_vien(decimal ip_dc_id_nhan_vien, int ip_int_thang, int ip_int_nam)
 //{
 //    US_RPT_LUONG v_us = new US_RPT_LUONG();
 //    DataSet v_ds = new DataSet();
 //    v_ds.Tables.Add(new DataTable());
 //    v_us.FillBangLuong(v_ds, ip_dc_id_nhan_vien, ip_int_thang, ip_int_nam);
 //    DataRow v_dr = v_ds.Tables[0].Rows[0];
 //    return v_dr;
 //}
 public void DataRow2US(DataRow v_dr_luong_1_nv, US_RPT_LUONG v_us)
 {
     v_us.strMA_NV = v_dr_luong_1_nv[RPT_LUONG.MA_NV].ToString();
     v_us.dcAN_CA = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.AN_CA].ToString());
     v_us.dcBHTN = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.BHTN].ToString());
     v_us.dcBHXH = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.BHXH].ToString());
     v_us.dcBHYT = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.BHYT].ToString());
     v_us.dcDOAN_PHI_CD = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.DOAN_PHI_CD].ToString());
     v_us.dcID_NHAN_VIEN = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.ID_NHAN_VIEN].ToString());
     v_us.dcLAM_THEM = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.LAM_THEM].ToString());
     v_us.dcLAM_THEM_LE_TET = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.LAM_THEM_LE_TET].ToString());
     v_us.dcLUONG_CD = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.LUONG_CD].ToString());
     v_us.dcLUONG_NS = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.LUONG_NS].ToString());
     v_us.dcNAM = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.NAM].ToString());
     v_us.dcPHAI_NOP = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.PHAI_NOP].ToString());
     v_us.dcPHU_CAP_TN = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.PHU_CAP_TN].ToString());
     v_us.dcTHANG = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.THANG].ToString());
     v_us.dcTHU_NHAP = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.THU_NHAP].ToString());
     v_us.dcTHUC_LINH = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.THUC_LINH].ToString());
     v_us.dcTHUC_LINH_CUOI_CUNG = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.THUC_LINH_CUOI_CUNG].ToString());
     v_us.dcTHUE = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.THUE].ToString());
     v_us.dcTRUY_LINH = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.TRUY_LINH].ToString());
     v_us.dcTRUY_THU = CIPConvert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.TRUY_THU].ToString());
     v_us.dcSO_NGAY_LAM_THEM = Convert.ToDecimal(v_dr_luong_1_nv[RPT_LUONG.SO_NGAY_LAM_THEM]);
 }
 public static DataRow get_luong_1_nhan_vien(decimal ip_dc_id_nhan_vien, int ip_int_thang, int ip_int_nam)
 {
     US_RPT_LUONG v_us = new US_RPT_LUONG();
     DataSet v_ds = new DataSet();
     v_ds.Tables.Add(new DataTable());
     v_us.FillBangLuong(v_ds, ip_dc_id_nhan_vien, ip_int_thang, ip_int_nam);
     DataRow v_dr = v_ds.Tables[0].Rows[0];
     return v_dr;
 }
        private bool bang_luong_thang_do_da_tinh(decimal v_id_nhan_vien, int ip_dat_thang, int ip_dat_nam)
        {
            DS_RPT_LUONG v_ds = new DS_RPT_LUONG();
            US_RPT_LUONG v_us = new US_RPT_LUONG();
            v_us.FillDataset(v_ds, "WHERE ID_NHAN_VIEN = " + v_id_nhan_vien + " AND THANG = " + ip_dat_thang + " AND  NAM = " + ip_dat_nam + "");

            if (v_ds.Tables[0].Rows.Count != 0)
            {
                return true;
            }
            else
                return false;
        }
 private void xoa_bang_luong_thang()
 {
     //B1: Xoa het bang luong thang do
     US_RPT_LUONG v_us_rpt_luong = new US_RPT_LUONG();
     v_us_rpt_luong.XoaLuong(Convert.ToDecimal(m_txt_thang.EditValue), Convert.ToDecimal(m_txt_nam.EditValue));
 }
 private void tinh_toan_qtr_tinh_luong(out decimal op_dc_sl_nv_can_tinh, out decimal op_dc_sl_nv_da_tinh)
 {
     US_RPT_LUONG v_us_rpt = new US_RPT_LUONG();
     v_us_rpt.get_thong_tin_qua_trinh_tinh_luong(CIPConvert.ToDecimal(m_txt_thang.Text.Trim())
                                                         , CIPConvert.ToDecimal(m_txt_nam.Text.Trim())
                                                         , out op_dc_sl_nv_can_tinh
                                                         , out op_dc_sl_nv_da_tinh);
 }
        private void tinh_bang_luong(BackgroundWorker ip_bgw)
        {
            if(is_da_chot_bang_luong())
                return;

            US_RPT_LUONG v_us_rpt_luong = new US_RPT_LUONG();
            DS_RPT_LUONG v_ds_rpt_luong;
            //1. Lấy tất cả nhân viên cần tính lương
            v_us_rpt_luong.Get_tat_ca_nhan_vien_can_tinh_luong(
                                out v_ds_rpt_luong
                                , CIPConvert.ToDecimal(m_txt_thang.EditValue)
                                , CIPConvert.ToDecimal(m_txt_nam.EditValue));
            //2. Tính lương cho tất cả nhân viên
            tinh_bang_luong_tat_ca_nhan_vien(v_ds_rpt_luong.RPT_LUONG, ip_bgw);
        }
        //public void insertLuongNV2RPT(DataRow v_dr_luong_1_nv)
        //{
        //    US_RPT_LUONG v_us = new US_RPT_LUONG();
        //    DataRow2US(v_dr_luong_1_nv, v_us);
        //    v_us.Insert();
        //}
        private void m_cmd_tinh_lai_cho_nhan_vien_Click(object sender, EventArgs e)
        {
            try
            {
                if(m_grv.FocusedRowHandle < 0)
                {
                    XtraMessageBox.Show("Chọn nhân viên trước để tính lại lương!", "THÔNG BÁO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }
                decimal v_id_nhan_vien = Convert.ToDecimal(m_grv.GetRowCellValue(m_grv.FocusedRowHandle, "ID_NHAN_VIEN"));

                DataRow v_dr_luong = get_luong_1_nhan_vien(v_id_nhan_vien, int.Parse(m_txt_thang.Text.Trim()), int.Parse(m_txt_nam.Text.Trim()));

                var v_dr_luong_nv = m_ds_rpt_luong.Tables[0].NewRow();
                DataRow v_dr_luong_1_nv = get_dr(v_dr_luong_nv, v_dr_luong, v_id_nhan_vien, 0, int.Parse(m_txt_thang.Text.Trim()), int.Parse(m_txt_nam.Text.Trim()));

                //Xoa ban ghi truoc khi insert lai
                US_RPT_LUONG v_us_2_del = new US_RPT_LUONG();
                v_us_2_del.XoaBanGhiLuong(v_id_nhan_vien, Convert.ToDecimal(m_txt_thang.EditValue), Convert.ToDecimal(m_txt_nam.EditValue));
                insertLuongNV2RPT(v_dr_luong_1_nv);
                load_data_2_grid();
                XtraMessageBox.Show("Cập nhật thành công");
            }
            catch(Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }
 private void load_data_2_grid()
 {
     US_RPT_LUONG v_us = new US_RPT_LUONG();
     DataSet v_ds = new DataSet();
     v_ds.Tables.Add(new DataTable());
     v_us.HienThiBangLuong(v_ds, Convert.ToDecimal(m_txt_thang.Text), Convert.ToDecimal(m_txt_nam.Text));
     m_grc.DataSource = v_ds.Tables[0];
 }
 public void insertLuongNV2RPT(DataRow v_dr_luong_1_nv)
 {
     US_RPT_LUONG v_us = new US_RPT_LUONG();
     DataRow2US(v_dr_luong_1_nv, v_us);
     v_us.Insert();
 }
        private int find_id_rpt_luong(decimal v_id_nhan_vien, int ip_dat_thang, int ip_dat_nam)
        {
            DS_RPT_LUONG v_ds = new DS_RPT_LUONG();
            US_RPT_LUONG v_us = new US_RPT_LUONG();
            v_us.FillDataset(v_ds);

            string v_str_filter = "ID_NHAN_VIEN = " + v_id_nhan_vien + " AND THANG = " + ip_dat_thang + " AND  NAM = " + ip_dat_nam;
            DataRow[] v_dr = v_ds.RPT_LUONG.Select(v_str_filter);

            if (v_dr.Count() == 0)
            {
                return -1;
            }
            else
            {
                return int.Parse(v_dr.First()["ID"].ToString());
            }
        }