public void display_4_update(US_DM_THUE ip_us)
        {
            this.Text = "F109 - Sửa mức thuế";
            m_lbl_header.Text = "SỬA MỨC THUẾ";
            m_e_form_mode = DataEntryFormMode.UpdateDataState;
            m_id_dm_thue_4_update = ip_us.dcID;
            m_txt_chan_duoi.Text = ip_us.dcCHAN_DUOI.ToString();
            m_txt_chan_tren.Text = ip_us.dcCHAN_TREN.ToString();
            m_txt_ti_le.Text = (ip_us.dcTI_LE*100).ToString();
            m_txt_bu_tru.Text = ip_us.dcBU_TRU.ToString().Substring(ip_us.dcBU_TRU.ToString().LastIndexOf("-") + 1);

            CHRMCommon.format_text_2_money(m_txt_chan_duoi);
            CHRMCommon.format_text_2_money(m_txt_chan_tren);
            CHRMCommon.format_text_2_money(m_txt_bu_tru);

            this.CenterToScreen();
            this.ShowDialog();
        }
        private void focus_new_row_created(decimal ip_dc_id_gd_phu_thuoc_details)
        {
            int v_row_index = 0;
            decimal v_id_qd_moi_lap = 0;

            US_DM_THUE v_us = new US_DM_THUE();
            DS_DM_THUE v_ds = new DS_DM_THUE();

            v_id_qd_moi_lap = ip_dc_id_gd_phu_thuoc_details;

            v_us.FillDataset(v_ds);

            for (v_row_index = 0; v_row_index < v_ds.Tables[0].Rows.Count; v_row_index++)
            {
                var v_id_gd_qd = CIPConvert.ToDecimal(m_grv1.GetDataRow(v_row_index)["ID"].ToString());

                if (v_id_gd_qd == v_id_qd_moi_lap)
                {
                    break;
                }
            }

            m_grv1.FocusedRowHandle = v_row_index;
        }
        private void fill_data_2_grid_from_excel_thue_thang(string ip_str_path)
        {
            try
            {
                splashScreenManager1.ShowWaitForm();
                if(ip_str_path == "")
                {
                    return;
                }

                //m_grv_main.Columns.Clear();
                WinFormControls.load_xls_to_gridview(ip_str_path, m_grc_main);
                var v_dr = (DataRow)m_sle_quy_tien_thuong.Properties.View.GetFocusedDataRow();
                var v_tong_tien = (decimal)v_dr["SO_TIEN"];
                var datasource = (DataTable)m_grc_main.DataSource;
                //Lay tong he so
                decimal tong_he_so = 0;
                foreach(DataRow item in datasource.Rows)
                {
                    if(item["HS_THUONG"] != DBNull.Value)
                    {
                        tong_he_so = tong_he_so + Convert.ToDecimal(item["HS_THUONG"]);
                    }

                }
                if(tong_he_so == 0)
                {
                    MessageBox.Show("Lỗi do tổng hệ số thưởng = 0");
                    return;
                }
                //
                foreach(DataRow item in datasource.Rows)
                {
                    if(item["HS_THUONG"] != DBNull.Value)
                    {
                        var thanh_tien = v_tong_tien / tong_he_so * Convert.ToDecimal(item["HS_THUONG"]);
                        item["THANH_TIEN"] = thanh_tien;

                        US_DUNG_CHUNG v_us = new US_DUNG_CHUNG();
                        DataSet v_ds = new DataSet();
                        v_ds.Tables.Add();

                        US_DM_THUE v_us_thue = new US_DM_THUE();
                        decimal v_thue_nhan_vien = v_us_thue.LayThueTheoTien(thanh_tien, Convert.ToDecimal(item["ID"]));
                        //Tinh thue o day
                        item["THUE"] = v_thue_nhan_vien;
                        item["THUC_LINH"] = Convert.ToDecimal(item["THANH_TIEN"]) - Convert.ToDecimal(item["THUE"]);
                        item["THUC_LINH_CUOI_CUNG"] = Convert.ToDecimal(item["THUC_LINH"]) + Convert.ToDecimal(item["TRUY_LINH"]) - Convert.ToDecimal(item["TRUY_THU"]);
                    }
                }
                m_b_imported = true;
                m_grc_main.Visible = true;
                layoutControlItemGrid.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
                layoutControlItemSave.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always;
            }
            catch(Exception)
            {
                throw;
            }
            finally { splashScreenManager1.CloseWaitForm(); }
        }
 private void load_data_2_grid()
 {
     CHRMCommon.make_stt(m_grv_dm_thue);
     US_DM_THUE v_us = new US_DM_THUE();
     DS_DM_THUE v_ds = new DS_DM_THUE();
     v_us.FillDataset(v_ds);
     //US_DUNG_CHUNG v_us = new US_DUNG_CHUNG();
     //DataSet v_ds = new DataSet();
     //v_ds.Tables.Add(new DataTable());
     //throw new Exception("Sua lai khong dung FillDataSetWithTableName nua nhe");
     //v_us.FillDatasetWithTableName(v_ds, "DM_THUE");
     m_grc_dm_thue.DataSource = v_ds.Tables[0];
 }
        void m_cmd_update_Click(object sender, EventArgs e)
        {
            try
            {
                decimal v_id_dm_thue = CIPConvert.ToDecimal(m_grv_dm_thue.GetRowCellValue(m_grv_dm_thue.FocusedRowHandle, "ID"));

                if (v_id_dm_thue > 0)
                {
                    US_DM_THUE v_us = new US_DM_THUE(v_id_dm_thue);
                    F109_dm_thue_de v_frm = new F109_dm_thue_de();
                    v_frm.display_4_update(v_us);
                    load_data_2_grid();

                    focus_new_row_created(v_id_dm_thue);
                }
                else
                {
                    CHRM_BaseMessages.MsgBox_Error(CONST_ID_MSGBOX.ERROR_CHUA_CHON_DONG_TREN_LUOI_DE_SUA);
                }
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }
        void m_cmd_delete_Click(object sender, EventArgs e)
        {
            try
            {
                if (CHRM_BaseMessages.MsgBox_Confirm(CONST_ID_MSGBOX.QUESTION_XAC_NHAN_XOA_DU_LIEU) == true)
                {
                    DataRow v_dr = m_grv_dm_thue.GetDataRow(m_grv_dm_thue.FocusedRowHandle);
                    decimal v_id_dm_thue = CIPConvert.ToDecimal(v_dr["ID"]);

                    US_DM_THUE v_us = new US_DM_THUE(v_id_dm_thue);
                    v_us.BeginTransaction();
                    v_us.Delete();
                    v_us.CommitTransaction();
                    load_data_2_grid();
                    CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_XOA_DU_LIEU_THANH_CONG);
                }
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }
        private void save_data()
        {
            US_DM_THUE v_us_dm_thue = new US_DM_THUE();
            form_2_us_obj(v_us_dm_thue);

            try
            {
                switch (m_e_form_mode)
                {
                    case DataEntryFormMode.InsertDataState:
                        v_us_dm_thue.BeginTransaction();
                        v_us_dm_thue.Insert();
                        v_us_dm_thue.CommitTransaction();
                        m_id_dm_thue_moi_tao = v_us_dm_thue.dcID;
                        if (CHRM_BaseMessages.MsgBox_Confirm(CONST_ID_MSGBOX.QUESTION_INSER_DM_THUE_THANH_CONG_TIEP_TUC_INSERT_YN) == true)
                        {
                            refresh_form();
                        }
                        else
                        {
                            this.Close();
                        }
                        break;
                    case DataEntryFormMode.UpdateDataState:
                        v_us_dm_thue.dcID = m_id_dm_thue_4_update;
                        v_us_dm_thue.BeginTransaction();
                        v_us_dm_thue.Update();
                        v_us_dm_thue.CommitTransaction();
                        CHRM_BaseMessages.MsgBox_Infor(CONST_ID_MSGBOX.INFOR_DU_LIEU_DA_DUOC_CAP_NHAT);
                        this.Close();
                        break;
                    default:
                        break;
                }
            }
            catch (Exception v_e)
            {
                throw v_e;
            }
        }
 //save data
 private void form_2_us_obj(US_DM_THUE ip_us)
 {
     ip_us.dcCHAN_DUOI = CIPConvert.ToDecimal(m_txt_chan_duoi.Text.Trim());
     ip_us.dcCHAN_TREN = CIPConvert.ToDecimal(m_txt_chan_tren.Text.Trim());
     ip_us.dcTI_LE = CIPConvert.ToDecimal(m_txt_ti_le.Text.Trim()) / 100;
     ip_us.dcBU_TRU = 0 - CIPConvert.ToDecimal(m_txt_bu_tru.Text.Trim());
 }