protected void m_cmd_de_nghi_xu_ly_Click(object sender, EventArgs e)
 {
     try
     {
         Thread.Sleep(1000);
         foreach (GridViewRow row in m_grv_dm_oto.Rows)
         {
             bool v_ch;
             CheckBox v_checkbox = (CheckBox)row.FindControl("chkItem");
             if (v_checkbox != null)
             {
                 // Nếu checkbox của dòng này được checked thì ta thực hiện 1 số công việc sau
                 if (v_checkbox.Checked)
                 {
                     // Chỗ này là công việc cần thực hiện khi checkbox đc checkded
                     decimal v_id = CIPConvert.ToDecimal(m_grv_dm_oto.DataKeys[row.RowIndex].Value);
                     m_us_dm_oto = new US_DM_OTO(v_id);
                     m_us_dm_oto.dcID_TRANG_THAI = ID_TRANG_THAI_OTO.DE_NGHI_XU_LY;
                     m_us_dm_oto.Update();
                 }
             }
         }
         // Hiển thị các ID được checked ra màn hình
         Response.Write(m_str_id_checked);
         load_data_to_grid();
         set_trang_thai_cmd();
         m_lbl_mess.Text = "Đã cập nhật thành công";
         m_ddl_bo_tinh.Focus();
     }
     catch (Exception v_e)
     {
         CSystemLog_301.ExceptionHandle(v_e);
     }
 }
    private void set_gia_tri_hien_trang(US_DM_OTO ip_us_dm_oto)
    {
        string v_str_hien_trang = m_rbl_muc_dich_su_dung.SelectedValue;
        ip_us_dm_oto.dcQLNN = 0;
        ip_us_dm_oto.dcKINH_DOANH = 0;
        ip_us_dm_oto.dcKHONG_KINH_DOANH = 0;
        ip_us_dm_oto.dcHD_KHAC = 0;

        switch (v_str_hien_trang)
        {
            case "QLNN":
                ip_us_dm_oto.dcQLNN = 1;
                break;
            case "KD":
                ip_us_dm_oto.dcKINH_DOANH = 1;
                break;
            case "KKD":
                ip_us_dm_oto.dcKHONG_KINH_DOANH = 1;
                break;
            case "MDK":
                ip_us_dm_oto.dcHD_KHAC = 1;
                break;
        }
    }
 private void load_gia_tri_hien_trang(US_DM_OTO ip_us_dm_oto)
 {
     if ( ip_us_dm_oto.dcQLNN == 1)
     {
         m_rbl_muc_dich_su_dung.SelectedValue = "QLNN";
         return;
     }
     if ( ip_us_dm_oto.dcKINH_DOANH == 1)
     {
         m_rbl_muc_dich_su_dung.SelectedValue = "KD";
         return;
     }
     if ( ip_us_dm_oto.dcKHONG_KINH_DOANH == 1)
     {
         m_rbl_muc_dich_su_dung.SelectedValue = "KKD";
         return;
     }
     if ( ip_us_dm_oto.dcHD_KHAC == 1)
     {
         m_rbl_muc_dich_su_dung.SelectedValue = "MDK";
         return;
     }
 }
 private void xoa_khau_hao(decimal ip_dc_id_kh, decimal ip_dc_id_oto, decimal ip_dc_gia_tri_kh)
 {
     US_DM_OTO v_us_dm_oto = new US_DM_OTO(ip_dc_id_oto);
     m_us_gd_kh.DeleteByID(ip_dc_id_kh);
     v_us_dm_oto.dcGIA_TRI_CON_LAI += ip_dc_gia_tri_kh;
     v_us_dm_oto.Update();
     m_lbl_message.Text = "Đã xóa thành công bản ghi";
 }
 private void them_moi_khau_hao()
 {
     decimal v_dc_id_tai_san = CIPConvert.ToDecimal(m_cbo_ten_tai_san.SelectedValue);
     US_GD_KHAU_HAO v_us_gd_khau_hao = new US_GD_KHAU_HAO();
     US_DM_OTO v_us_dm_oto = new US_DM_OTO(v_dc_id_tai_san);
     decimal v_dc_gia_tri_khau_hao = CIPConvert.ToDecimal(m_txt_gia_tri_khau_hao.Text);
     // Lấy thông tin mới cho giao dịch khấu hao
     v_us_gd_khau_hao.dcID_TAI_SAN = v_dc_id_tai_san;
     v_us_gd_khau_hao.dcID_LOAI_TAI_SAN = v_us_dm_oto.dcID_LOAI_TAI_SAN;
     v_us_gd_khau_hao.dcID_DON_VI = v_us_dm_oto.dcID_DON_VI_SU_DUNG;
     v_us_gd_khau_hao.dcGIA_TRI_KHAU_HAO = v_dc_gia_tri_khau_hao;
     v_us_gd_khau_hao.strMA_PHIEU = m_txt_ma_phieu.Text;
     v_us_gd_khau_hao.datNGAY_DUYET = CIPConvert.ToDatetime(m_txt_ngay_duyet.Text);
     v_us_gd_khau_hao.datNGAY_LAP = CIPConvert.ToDatetime(m_txt_ngay_lap.Text);
     v_us_gd_khau_hao.dcID_NGUOI_LAP = Person.get_user_id();
     v_us_gd_khau_hao.dcID_NGUOI_DUYET = Person.get_user_id();
     // Cập nhật cho nhà
     v_us_dm_oto.dcGIA_TRI_CON_LAI = v_us_dm_oto.dcGIA_TRI_CON_LAI - v_dc_gia_tri_khau_hao;
     // Thực hiện cập nhật
     v_us_gd_khau_hao.Insert();
     v_us_dm_oto.Update();
     m_lbl_message.Text = "Cập nhật thành công";
 }
    private void update_thong_tin_tai_san(US_DM_OTO op_us_dm_oto)
    {
        US_DM_DON_VI v_us_dm_don_vi = new US_DM_DON_VI();
        string v_str_ma_don_vi = new Random().Next(1000).ToString();
        v_us_dm_don_vi.strMA_DON_VI = v_str_ma_don_vi;
        v_us_dm_don_vi.dcID_DON_VI_CAP_TREN = ID_DON_VI.DON_VI_CHU_QUAN_KHAC;
        v_us_dm_don_vi.dcID_LOAI_DON_VI = ID_LOAI_DON_VI.DV_SU_DUNG;
        v_us_dm_don_vi.dcLEVEL_MODE = 3;
        v_us_dm_don_vi.strTEN_DON_VI = m_txt_don_vi_nhan_dieu_chuyen.Text.Trim();
        v_us_dm_don_vi.strLOAI_HINH_DON_VI = TEN_LOAI_HINH_DON_VI.DON_VI_SU_NGHIEP_CTCTC;

        v_us_dm_don_vi.Insert();

        decimal v_id_don_vi_moi = v_us_dm_don_vi.dcID;
        v_us_dm_don_vi.strMA_DON_VI = "DVK" + v_id_don_vi_moi.ToString();
        v_us_dm_don_vi.Update();

        US_HT_QUAN_HE_SU_DUNG_DU_LIEU v_us_ht_qhsddl = new US_HT_QUAN_HE_SU_DUNG_DU_LIEU();
        v_us_ht_qhsddl.dcID_DON_VI = v_us_dm_don_vi.dcID;
        v_us_ht_qhsddl.dcID_USER_GROUP = 2;
        v_us_ht_qhsddl.Insert();

        v_us_ht_qhsddl = new US_HT_QUAN_HE_SU_DUNG_DU_LIEU();
        v_us_ht_qhsddl.dcID_DON_VI = v_us_dm_don_vi.dcID;
        v_us_ht_qhsddl.dcID_USER_GROUP = 5;
        v_us_ht_qhsddl.Insert();

        op_us_dm_oto.dcID_DON_VI_SU_DUNG = v_us_dm_don_vi.dcID;
        op_us_dm_oto.dcID_DON_VI_CHU_QUAN = ID_DON_VI.DON_VI_CHU_QUAN_KHAC;
    }
    private void them_moi_tang_giam()
    {
        US_GD_TANG_GIAM_TAI_SAN v_us_gd_tang_giam_tai_san = new US_GD_TANG_GIAM_TAI_SAN();
        m_us_dm_oto = new US_DM_OTO(CIPConvert.ToDecimal(m_hdf_id.Value));
        v_us_gd_tang_giam_tai_san.datNGAY_DUYET = CIPConvert.ToDatetime(m_txt_ngay_duyet.Text);
        v_us_gd_tang_giam_tai_san.datNGAY_TANG_GIAM_TAI_SAN = CIPConvert.ToDatetime(m_txt_ngay_tang_giam.Text);
        v_us_gd_tang_giam_tai_san.dcID_LY_DO_TANG_GIAM = CIPConvert.ToDecimal(m_cbo_ly_do_thay_doi.SelectedValue);
        v_us_gd_tang_giam_tai_san.strTANG_GIA_TRI_TAI_SAN_YN = m_rbl_loai.SelectedValue;

        v_us_gd_tang_giam_tai_san.dcID_TAI_SAN = m_us_dm_oto.dcID;
        v_us_gd_tang_giam_tai_san.dcID_LOAI_TAI_SAN = m_us_dm_oto.dcID_LOAI_TAI_SAN;
        v_us_gd_tang_giam_tai_san.strMA_PHIEU = m_txt_ma_phieu.Text;
        v_us_gd_tang_giam_tai_san.dcDIEN_TICH = m_us_dm_oto.dcKINH_DOANH + m_us_dm_oto.dcKHONG_KINH_DOANH;
        v_us_gd_tang_giam_tai_san.dcGIA_TRI_NGUYEN_GIA_TANG_GIAM = m_us_dm_oto.dcNGUON_NS + m_us_dm_oto.dcNGUON_KHAC;

        v_us_gd_tang_giam_tai_san.dcID_NGUOI_LAP = Person.get_user_id();
        v_us_gd_tang_giam_tai_san.dcID_NGUOI_DUYET = Person.get_user_id();

        v_us_gd_tang_giam_tai_san.Insert();

        // Phần cập nhật thông tin cho DM
        set_form_mode();
        WinFormControls.load_data_to_cbo_bo_tinh(
             WinFormControls.eTAT_CA.NO
             , m_ddl_bo_tinh);
        WinFormControls.load_data_to_cbo_don_vi_chu_quan(
            m_ddl_bo_tinh.SelectedValue
            , WinFormControls.eTAT_CA.NO
            , m_ddl_dv_chu_quan);
        WinFormControls.load_data_to_cbo_don_vi_su_dung(
            m_ddl_dv_chu_quan.SelectedValue
            , m_ddl_bo_tinh.SelectedValue
            , WinFormControls.eTAT_CA.NO
            , m_ddl_dv_sd_ts);
        load_2_cbo_loaits();
        load_data_trang_thai();
        load_data_to_grid();
    }
 private void form_2_us_object(US_DM_OTO ip_us_oto)
 {
     ip_us_oto.dcID_NGUOI_LAP = CIPConvert.ToDecimal(Person.get_user_id());
     if (!m_hdf_id.Value.Equals(String.Empty))
     {
         ip_us_oto.dcID = CIPConvert.ToDecimal(m_hdf_id.Value);
     }
     ip_us_oto.strNGUON_GOC_XE = m_txt_nguon_goc_xe.Text;
     ip_us_oto.dcSO_CHO_NGOI = CIPConvert.ToDecimal(m_txt_tai_trong.Text);
     ip_us_oto.dcCONG_SUAT_XE = CIPConvert.ToDecimal(m_txt_cong_suat_xe.Text);
     ip_us_oto.datNGAY_CAP_NHAT_CUOI = DateTime.Now;
     ip_us_oto.dcNAM_SU_DUNG = CIPConvert.ToDecimal(m_txt_nam_su_dung.Text);
     ip_us_oto.dcNAM_SAN_XUAT = CIPConvert.ToDecimal(m_txt_nam_san_xuat.Text);
     ip_us_oto.dcGIA_TRI_CON_LAI = CIPConvert.ToDecimal(m_txt_gia_tri_con_lai.Text);
     ip_us_oto.dcHD_KHAC = CIPConvert.ToDecimal(m_txt_hd_khac.Text);
     ip_us_oto.dcKHONG_KINH_DOANH = CIPConvert.ToDecimal(m_txt_khong_kinh_doanh.Text);
     ip_us_oto.dcKINH_DOANH = CIPConvert.ToDecimal(m_txt_kinh_doanh.Text);
     ip_us_oto.dcNGUON_KHAC = CIPConvert.ToDecimal(m_txt_nguon_khac.Text);
     ip_us_oto.dcNGUON_NS = CIPConvert.ToDecimal(m_txt_nguon_ns.Text);
     ip_us_oto.dcQLNN = CIPConvert.ToDecimal(m_txt_qlnn.Text);
     ip_us_oto.strBIEN_KIEM_SOAT = m_txt_bien_kiem_soat.Text;
     ip_us_oto.strCHUC_DANH_SU_DUNG = m_txt_chuc_danh_sd_xe.Text;
     ip_us_oto.strNGUON_GOC_XE = m_txt_nguon_goc_xe.Text;
     ip_us_oto.strNHAN_HIEU = m_txt_ten_nhan_hieu.Text;
     ip_us_oto.strNUOC_SAN_XUAT = m_txt_nuoc_san_xuat.Text;
     ip_us_oto.strMA_TAI_SAN = m_txt_ma_ts.Text;
     ip_us_oto.strTEN_TAI_SAN = m_txt_ten_ts.Text;
     ip_us_oto.datNGAY_CAP_NHAT_CUOI = DateTime.Now;
     ip_us_oto.dcID_TRANG_THAI = CIPConvert.ToDecimal(m_ddl_trang_thai_oto.SelectedValue);
     ip_us_oto.dcID_LOAI_TAI_SAN = CIPConvert.ToDecimal(m_ddl_loai_xe.SelectedValue);
     ip_us_oto.dcID_DON_VI_SU_DUNG = CIPConvert.ToDecimal(m_ddl_dv_sd_ts.SelectedValue);
     ip_us_oto.dcID_DON_VI_CHU_QUAN = CIPConvert.ToDecimal(m_ddl_dv_chu_quan.SelectedValue);
 }
 private void cap_nhat_thong_tin_tai_san()
 {
     US_DM_OTO v_us_dm_oto = new US_DM_OTO(CIPConvert.ToDecimal(m_cbo_ten_tai_san.SelectedValue));
     v_us_dm_oto.dcID_TRANG_THAI = ID_TRANG_THAI_OTO.DANG_SU_DUNG;
     v_us_dm_oto.dcID_DON_VI_SU_DUNG = CIPConvert.ToDecimal(m_cbo_don_vi_su_dung_moi.SelectedValue);
     v_us_dm_oto.Update();
     string v_str_dv_cu = m_cbo_don_vi_su_dung_tai_san_up.SelectedItem.Text;
     string v_str_dv_moi = m_cbo_don_vi_su_dung_moi.SelectedItem.Text;
     m_lbl_message.Text = "Đã điều chuyển tài sản " + v_us_dm_oto.strTEN_TAI_SAN
         + " từ đơn vị " + v_str_dv_cu + " đến đơn vị " + v_str_dv_moi;
 }
 private void us_object2grid(US_DM_OTO i_us
     , int i_grid_row)
 {
     DataRow v_dr = (DataRow)m_fg_oto.Rows[i_grid_row].UserData;
     i_us.Me2DataRow(v_dr);
     m_obj_trans.DataRow2GridRow(v_dr, i_grid_row);
 }
    private void them_moi_tang_giam()
    {
        US_DM_OTO v_us_dm_oto = new US_DM_OTO(CIPConvert.ToDecimal(m_cbo_ten_tai_san.SelectedValue));
        m_us_gd_tang_giam_tai_san = new US_GD_TANG_GIAM_TAI_SAN();
        m_us_gd_tang_giam_tai_san.datNGAY_DUYET = CIPConvert.ToDatetime(m_txt_ngay_duyet.Text);
        m_us_gd_tang_giam_tai_san.datNGAY_TANG_GIAM_TAI_SAN = CIPConvert.ToDatetime(m_txt_ngay_tang_giam.Text);
        m_us_gd_tang_giam_tai_san.dcID_LY_DO_TANG_GIAM = CIPConvert.ToDecimal(m_cbo_ly_do_thay_doi.SelectedValue);
        m_us_gd_tang_giam_tai_san.strTANG_GIA_TRI_TAI_SAN_YN = m_rbl_loai.SelectedValue;

        m_us_gd_tang_giam_tai_san.dcID_TAI_SAN = v_us_dm_oto.dcID;
        m_us_gd_tang_giam_tai_san.dcID_LOAI_TAI_SAN = v_us_dm_oto.dcID_LOAI_TAI_SAN;
        m_us_gd_tang_giam_tai_san.strMA_PHIEU = m_txt_ma_phieu.Text;
        m_us_gd_tang_giam_tai_san.dcDIEN_TICH = v_us_dm_oto.dcKINH_DOANH + v_us_dm_oto.dcKHONG_KINH_DOANH;
        m_us_gd_tang_giam_tai_san.dcGIA_TRI_NGUYEN_GIA_TANG_GIAM = v_us_dm_oto.dcNGUON_NS + v_us_dm_oto.dcNGUON_KHAC;

        m_us_gd_tang_giam_tai_san.dcID_NGUOI_LAP = Person.get_user_id();
        m_us_gd_tang_giam_tai_san.dcID_NGUOI_DUYET = Person.get_user_id();

        m_us_gd_tang_giam_tai_san.Insert();

        // Phần cập nhật thông tin cho DM
        if (m_rbl_loai.SelectedValue == "N")
        {
            v_us_dm_oto.dcID_TRANG_THAI = ID_TRANG_THAI_OTO.DA_THANH_LY;
            v_us_dm_oto.Update();
        }
        m_lbl_message.Text = "Cập nhật thành công";
    }
 private void grid2us_object(US_DM_OTO i_us
     , int i_grid_row)
 {
     DataRow v_dr;
     v_dr = (DataRow)m_fg_oto.Rows[i_grid_row].UserData;
     m_obj_trans.GridRow2DataRow(i_grid_row, v_dr);
     i_us.DataRow2Me(v_dr);
 }
 private void delete_dm_oto()
 {
     if (!CGridUtils.IsThere_Any_NonFixed_Row(m_fg_oto)) return;
     if (!CGridUtils.isValid_NonFixed_RowIndex(m_fg_oto, m_fg_oto.Row)) return;
     if (BaseMessages.askUser_DataCouldBeDeleted(8) != BaseMessages.IsDataCouldBeDeleted.CouldBeDeleted) return;
     US_DM_OTO v_us = new US_DM_OTO();
     grid2us_object(v_us, m_fg_oto.Row);
     try
     {
         v_us.BeginTransaction();
         v_us.Delete();
         v_us.CommitTransaction();
         m_fg_oto.Rows.Remove(m_fg_oto.Row);
     }
     catch (Exception v_e)
     {
         v_us.Rollback();
         CDBExceptionHandler v_objErrHandler = new CDBExceptionHandler(v_e,
             new CDBClientDBExceptionInterpret());
         v_objErrHandler.showErrorMessage();
     }
 }
 private void us_2_form_for_update()
 {
     m_cbo_bo_tinh_up.Enabled = false;
     m_cbo_don_vi_chu_quan_up.Enabled = false;
     m_cbo_don_vi_su_dung_tai_san_up.Enabled = false;
     m_cbo_ten_tai_san.Enabled = false;
     m_cbo_ly_do_thay_doi.Enabled = false;
     US_DM_OTO v_us_dm_oto = new US_DM_OTO(m_us_gd_tang_giam_tai_san.dcID_TAI_SAN);
     m_lbl_ma_tai_san.Text = v_us_dm_oto.strMA_TAI_SAN;
     m_lbl_nhan_hieu.Text = v_us_dm_oto.strNHAN_HIEU;
     m_lbl_bien_kiem_soat.Text = v_us_dm_oto.strBIEN_KIEM_SOAT;
     m_lbl_chuc_dang_su_dung.Text = v_us_dm_oto.strCHUC_DANH_SU_DUNG;
     m_lbl_nuoc_san_xuat.Text = v_us_dm_oto.strNUOC_SAN_XUAT;
     m_lbl_nam_san_xuat.Text = v_us_dm_oto.dcNAM_SAN_XUAT.ToString();
     m_lbl_nam_su_dung.Text = v_us_dm_oto.dcNAM_SU_DUNG.ToString();
     m_lbl_nguyen_gia_nguon_ns.Text = v_us_dm_oto.dcNGUON_NS.ToString("#,##0");
     m_lbl_nguyen_gia_nguon_khac.Text = v_us_dm_oto.dcNGUON_KHAC.ToString("#,##0");
     m_lbl_gia_tri_con_lai.Text = v_us_dm_oto.dcGIA_TRI_CON_LAI.ToString("#,##0");
     m_txt_ma_phieu.Text = m_us_gd_tang_giam_tai_san.strMA_PHIEU;
     m_dat_ngay_duyet.SelectedDate = m_us_gd_tang_giam_tai_san.datNGAY_DUYET;
     m_dat_ngay_tang_giam.SelectedDate = m_us_gd_tang_giam_tai_san.datNGAY_TANG_GIAM_TAI_SAN;
     m_hdf_id.Value = m_us_gd_tang_giam_tai_san.dcID.ToString();
     m_txt_ma_phieu.Focus();
 }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            /*m_lbl_mess.Text = "";
            if (m_init_mode == DataEntryFormMode.UpdateDataState)
            {
                m_cmd_tao_moi.Enabled = false;
            }
            else
            {
                m_cmd_tao_moi.Enabled = true;
            }*/

            if (!IsPostBack)
            {
                set_form_mode();
                WinFormControls.load_data_to_cbo_bo_tinh(
                     WinFormControls.eTAT_CA.NO
                     , m_ddl_bo_tinh);
                WinFormControls.load_data_to_cbo_don_vi_chu_quan(
                    m_ddl_bo_tinh.SelectedValue
                    , WinFormControls.eTAT_CA.NO
                    , m_ddl_dv_chu_quan);
                WinFormControls.load_data_to_cbo_don_vi_su_dung(
                    m_ddl_dv_chu_quan.SelectedValue
                    , m_ddl_bo_tinh.SelectedValue
                    , WinFormControls.eTAT_CA.NO
                    , m_ddl_dv_sd_ts);
                load_2_cbo_loaits();
                load_data_trang_thai();
                load_data_to_grid();
                hidden_panel_tang_giam();
                //Code này là chức năng liên quan đến from F1000
                if (Request.QueryString[CONST_QLDB.MA_THAM_SO_URL.ID_OTO] != null)
                {
                    decimal v_dc_id_oto = CIPConvert.ToDecimal(Request.QueryString[CONST_QLDB.MA_THAM_SO_URL.ID_OTO]);
                    m_us_dm_oto = new US_DM_OTO(v_dc_id_oto);
                    us_obj_2_form(m_us_dm_oto);
                }
            }
        }
        catch (Exception v_e)
        {

            CSystemLog_301.ExceptionHandle(v_e);
        }
    }
    private void them_moi_ghi_giam()
    {
        US_DM_OTO v_us_dm_oto = new US_DM_OTO(CIPConvert.ToDecimal(m_cbo_ten_tai_san.SelectedValue));
        v_us_dm_oto.strMA_TAI_SAN = v_us_dm_oto.strMA_TAI_SAN + "-Cũ";
        v_us_dm_oto.dcID_TRANG_THAI = ID_KHAC.DIEU_CHUYEN_NOI_BO;
        v_us_dm_oto.Insert();

        m_us_gd_tang_giam_tai_san = new US_GD_TANG_GIAM_TAI_SAN();
        m_us_gd_tang_giam_tai_san.datNGAY_DUYET = m_dat_ngay_duyet.SelectedDate;
        m_us_gd_tang_giam_tai_san.datNGAY_TANG_GIAM_TAI_SAN = m_dat_ngay_tang_giam.SelectedDate;
        m_us_gd_tang_giam_tai_san.dcID_LY_DO_TANG_GIAM = ID_LY_DO_TANG_GIAM_TAI_SAN.DIEU_CHUYEN;
        m_us_gd_tang_giam_tai_san.strTANG_GIA_TRI_TAI_SAN_YN = "N";

        m_us_gd_tang_giam_tai_san.dcID_TAI_SAN = v_us_dm_oto.dcID;
        m_us_gd_tang_giam_tai_san.dcID_LOAI_TAI_SAN = v_us_dm_oto.dcID_LOAI_TAI_SAN;
        m_us_gd_tang_giam_tai_san.strMA_PHIEU = m_txt_ma_phieu_giam.Text;
        m_us_gd_tang_giam_tai_san.dcDIEN_TICH =
            v_us_dm_oto.dcKINH_DOANH + v_us_dm_oto.dcKHONG_KINH_DOANH + v_us_dm_oto.dcHD_KHAC + v_us_dm_oto.dcQLNN;
        m_us_gd_tang_giam_tai_san.dcGIA_TRI_NGUYEN_GIA_TANG_GIAM = v_us_dm_oto.dcNGUON_NS + v_us_dm_oto.dcNGUON_KHAC;

        m_us_gd_tang_giam_tai_san.dcID_NGUOI_LAP = Person.get_user_id();
        m_us_gd_tang_giam_tai_san.dcID_NGUOI_DUYET = Person.get_user_id();

        m_us_gd_tang_giam_tai_san.Insert();

        m_lbl_message.Text = "Cập nhật thành công";
        m_txt_tu_khoa.Text = m_us_gd_tang_giam_tai_san.strMA_PHIEU;
    }
    private bool check_validate_data_is_ok()
    {
        if (!CValidateTextBox.IsValid(m_txt_nam_su_dung, DataType.NumberType, allowNull.YES))
        {
            m_lbl_mess.Text = "Chưa nhập đúng năm sử dụng";
            return false;
        }
        if (!CValidateTextBox.IsValid(m_txt_nam_san_xuat, DataType.NumberType, allowNull.YES))
        {
            m_lbl_mess.Text = "Chưa nhập đúng năm sản xuất";
            return false;
        }
        if (!CValidateTextBox.IsValid(m_txt_qlnn, DataType.NumberType, allowNull.YES))
        {
            m_lbl_mess.Text = "Chưa nhập đúng quản lý nhà nước";
            return false;
        }
        if (!CValidateTextBox.IsValid(m_txt_kinh_doanh, DataType.NumberType, allowNull.YES))
        {
            m_lbl_mess.Text = "Chưa nhập đúng kinh doanh";
            return false;
        }
        if (!CValidateTextBox.IsValid(m_txt_khong_kinh_doanh, DataType.NumberType, allowNull.YES))
        {
            m_lbl_mess.Text = "Chưa nhập đúng không kinh doanh";
            return false;
        }
        if ((m_txt_nam_su_dung.Text.Trim().Length > 0) && (m_txt_nam_san_xuat.Text.Trim().Length > 0))
        {
            if (CIPConvert.ToDecimal(m_txt_nam_su_dung.Text) < CIPConvert.ToDecimal(m_txt_nam_san_xuat.Text))
            {
                m_lbl_mess.Text = "Năm sử dụng phải lớn hơn hoặc bằng năm sản xuất!";
                return false;
            }
        }
        if ((m_txt_nguon_ns.Text.Trim().Length > 0) & (m_txt_nguon_khac.Text.Trim().Length > 0) & (m_txt_gia_tri_con_lai.Text.Trim().Length > 0))
        {
            if (CIPConvert.ToDecimal(m_txt_nguon_ns.Text) + CIPConvert.ToDecimal(m_txt_nguon_khac.Text) < CIPConvert.ToDecimal(m_txt_gia_tri_con_lai.Text))
            {
                m_lbl_mess.Text = "Nguyên giá (nguồn ngân sách + nguồn khác) phải lớn hơn giá trị còn lại!";
                return false;
            }
        }

        if (m_init_mode == DataEntryFormMode.UpdateDataState)
        {
            m_us_dm_oto = new US_DM_OTO(CIPConvert.ToDecimal(m_hdf_id.Value));
            if (m_us_dm_oto.strMA_TAI_SAN != m_txt_ma_ts.Text)
            {
                if (!m_us_dm_oto.check_ma_valid(m_txt_ma_ts.Text))
                {
                    m_lbl_mess.Text = "Không thể cập nhật. Lỗi: Mã tài sản này đã tồn tại";
                    return false;
                }
            }
        }
        if (m_init_mode == DataEntryFormMode.InsertDataState)
        {
            if (!m_us_dm_oto.check_ma_valid(m_txt_ma_ts.Text.Trim()))
            {
                m_lbl_mess.Text = "Mã tài sản này đã tồn tại";
                return false;
            };
        }
        return true;
    }
    private void them_moi_ghi_tang()
    {
        US_DM_OTO v_us_dm_oto = new US_DM_OTO(CIPConvert.ToDecimal(m_cbo_ten_tai_san.SelectedValue));
        m_us_gd_tang_giam_tai_san = new US_GD_TANG_GIAM_TAI_SAN();
        m_us_gd_tang_giam_tai_san.datNGAY_DUYET = m_dat_duyet_dieu_chuyen.SelectedDate;
        m_us_gd_tang_giam_tai_san.datNGAY_TANG_GIAM_TAI_SAN = m_dat_nhan_dieu_chuyen.SelectedDate;
        m_us_gd_tang_giam_tai_san.dcID_LY_DO_TANG_GIAM = ID_LY_DO_TANG_GIAM_TAI_SAN.TRANG_CAP_MUA_MOI;
        m_us_gd_tang_giam_tai_san.strTANG_GIA_TRI_TAI_SAN_YN = "Y";

        m_us_gd_tang_giam_tai_san.dcID_TAI_SAN = v_us_dm_oto.dcID;
        m_us_gd_tang_giam_tai_san.dcID_LOAI_TAI_SAN = v_us_dm_oto.dcID_LOAI_TAI_SAN;
        m_us_gd_tang_giam_tai_san.strMA_PHIEU = m_txt_ma_phieu_tang.Text;
        m_us_gd_tang_giam_tai_san.dcDIEN_TICH =
            v_us_dm_oto.dcKINH_DOANH + v_us_dm_oto.dcKHONG_KINH_DOANH + v_us_dm_oto.dcHD_KHAC + v_us_dm_oto.dcQLNN;
        m_us_gd_tang_giam_tai_san.dcGIA_TRI_NGUYEN_GIA_TANG_GIAM = v_us_dm_oto.dcNGUON_NS + v_us_dm_oto.dcNGUON_KHAC;

        m_us_gd_tang_giam_tai_san.dcID_NGUOI_LAP = Person.get_user_id();
        m_us_gd_tang_giam_tai_san.dcID_NGUOI_DUYET = Person.get_user_id();

        m_us_gd_tang_giam_tai_san.Insert();

        m_lbl_message.Text = "Cập nhật thành công";
    }
 private void load_data_2_us_by_id(int ip_i_id)
 {
     decimal v_dc_id_dm_oto = CIPConvert.ToDecimal(m_grv_dm_oto.DataKeys[ip_i_id].Value);
     m_hdf_id.Value = v_dc_id_dm_oto.ToString();
     US_DM_OTO v_us_dm_oto = new US_DM_OTO(v_dc_id_dm_oto);
     m_hdf_id.Value = v_us_dm_oto.dcID.ToString();
     // Đẩy us lên form
     us_obj_2_form(v_us_dm_oto);
 }
 private void load_data_from_us()
 {
     clear_form_data();
     if (m_cbo_ten_tai_san.Items.Count == 0) return;
     decimal v_dc_id_oto = CIPConvert.ToDecimal(m_cbo_ten_tai_san.SelectedValue);
     if (v_dc_id_oto < 1) return;
     US_DM_OTO v_us_dm_oto = new US_DM_OTO(v_dc_id_oto);
     m_lbl_ma_tai_san.Text = v_us_dm_oto.strMA_TAI_SAN;
     m_lbl_nhan_hieu.Text = v_us_dm_oto.strNHAN_HIEU;
     m_lbl_bien_kiem_soat.Text = v_us_dm_oto.strBIEN_KIEM_SOAT;
     m_lbl_nuoc_san_xuat.Text = v_us_dm_oto.strNUOC_SAN_XUAT;
     m_lbl_nam_san_xuat.Text = v_us_dm_oto.dcNAM_SAN_XUAT.ToString();
     m_lbl_nam_su_dung.Text = v_us_dm_oto.dcNAM_SU_DUNG.ToString();
     m_lbl_chuc_dang_su_dung.Text = v_us_dm_oto.strCHUC_DANH_SU_DUNG;
     m_lbl_nguyen_gia_nguon_ns.Text = v_us_dm_oto.dcNGUON_NS.ToString("#,##0");
     m_lbl_nguyen_gia_nguon_khac.Text = v_us_dm_oto.dcNGUON_KHAC.ToString("#,##0");
     m_lbl_gia_tri_con_lai.Text = v_us_dm_oto.dcGIA_TRI_CON_LAI.ToString("#,##0");
 }
    /// <summary>
    /// Load dữ liệu từ US đổ vào form
    /// </summary>
    /// <param name="ip_dm_noi_dung_thanh_toan"></param>
    private void us_obj_2_form(US_DM_OTO ip_us_oto)
    {
        m_hdf_id.Value = ip_us_oto.dcID.ToString();
        m_txt_tai_trong.Text = ip_us_oto.dcSO_CHO_NGOI.ToString();
        m_txt_ma_ts.Text = ip_us_oto.strMA_TAI_SAN;
        m_txt_nam_su_dung.Text = ip_us_oto.dcNAM_SU_DUNG.ToString();
        m_txt_nam_san_xuat.Text = ip_us_oto.dcNAM_SAN_XUAT.ToString();
        m_txt_gia_tri_con_lai.Text = ip_us_oto.dcGIA_TRI_CON_LAI.ToString("#,##0.##");
        m_txt_ten_nhan_hieu.Text = ip_us_oto.strNHAN_HIEU;
        m_txt_nuoc_san_xuat.Text = ip_us_oto.strNUOC_SAN_XUAT;
        m_txt_bien_kiem_soat.Text = ip_us_oto.strBIEN_KIEM_SOAT;
        m_txt_chuc_danh_sd_xe.Text = ip_us_oto.strCHUC_DANH_SU_DUNG;
        m_txt_nguon_goc_xe.Text = ip_us_oto.strNGUON_GOC_XE;
        m_txt_cong_suat_xe.Text = ip_us_oto.dcCONG_SUAT_XE.ToString();
        m_txt_hd_khac.Text = ip_us_oto.dcHD_KHAC.ToString();
        m_txt_khong_kinh_doanh.Text = ip_us_oto.dcKHONG_KINH_DOANH.ToString();
        m_txt_kinh_doanh.Text = ip_us_oto.dcKINH_DOANH.ToString();
        m_txt_nguon_khac.Text = ip_us_oto.dcNGUON_KHAC.ToString("#,##0.##");
        m_txt_nguon_ns.Text = ip_us_oto.dcNGUON_NS.ToString("#,##0.##");
        m_txt_qlnn.Text = ip_us_oto.dcQLNN.ToString();
        m_txt_ten_ts.Text = ip_us_oto.strTEN_TAI_SAN;
        m_ddl_loai_xe.SelectedValue = ip_us_oto.dcID_LOAI_TAI_SAN.ToString();

        US_DM_DON_VI v_us_don_vi = new US_DM_DON_VI(ip_us_oto.dcID_DON_VI_CHU_QUAN);
        m_ddl_bo_tinh.SelectedValue = v_us_don_vi.dcID_DON_VI_CAP_TREN.ToString();

        WinFormControls.load_data_to_cbo_don_vi_chu_quan(
                   m_ddl_bo_tinh.SelectedValue
                   , WinFormControls.eTAT_CA.NO
                   , m_ddl_dv_chu_quan);

        m_ddl_dv_chu_quan.SelectedValue = ip_us_oto.dcID_DON_VI_CHU_QUAN.ToString();

        WinFormControls.load_data_to_cbo_don_vi_su_dung(
        m_ddl_dv_chu_quan.SelectedValue
        , m_ddl_bo_tinh.SelectedValue
        , WinFormControls.eTAT_CA.NO
        , m_ddl_dv_sd_ts);
        m_ddl_dv_sd_ts.SelectedValue = ip_us_oto.dcID_DON_VI_SU_DUNG.ToString();

        m_ddl_trang_thai_oto.SelectedValue = ip_us_oto.dcID_TRANG_THAI.ToString();
    }
    private void them_moi_tang_giam()
    {
        US_DM_OTO v_us_dm_oto = new US_DM_OTO(CIPConvert.ToDecimal(m_cbo_ten_tai_san.SelectedValue));
        m_us_gd_tang_giam_tai_san = new US_GD_TANG_GIAM_TAI_SAN();
        m_us_gd_tang_giam_tai_san.datNGAY_DUYET = m_dat_ngay_duyet.SelectedDate;
        m_us_gd_tang_giam_tai_san.datNGAY_TANG_GIAM_TAI_SAN = m_dat_ngay_tang_giam.SelectedDate;
        m_us_gd_tang_giam_tai_san.dcID_LY_DO_TANG_GIAM = CIPConvert.ToDecimal(m_cbo_ly_do_thay_doi.SelectedValue);
        m_us_gd_tang_giam_tai_san.strTANG_GIA_TRI_TAI_SAN_YN = m_rbl_loai.SelectedValue;

        m_us_gd_tang_giam_tai_san.dcID_TAI_SAN = v_us_dm_oto.dcID;
        m_us_gd_tang_giam_tai_san.dcID_LOAI_TAI_SAN = v_us_dm_oto.dcID_LOAI_TAI_SAN;
        m_us_gd_tang_giam_tai_san.strMA_PHIEU = m_txt_ma_phieu.Text;
        m_us_gd_tang_giam_tai_san.dcDIEN_TICH =
            v_us_dm_oto.dcKINH_DOANH + v_us_dm_oto.dcKHONG_KINH_DOANH + v_us_dm_oto.dcKINH_DOANH + v_us_dm_oto.dcKHONG_KINH_DOANH + v_us_dm_oto.dcHD_KHAC + v_us_dm_oto.dcQLNN;
        m_us_gd_tang_giam_tai_san.dcGIA_TRI_NGUYEN_GIA_TANG_GIAM = v_us_dm_oto.dcNGUON_NS + v_us_dm_oto.dcNGUON_KHAC;

        m_us_gd_tang_giam_tai_san.dcID_NGUOI_LAP = Person.get_user_id();
        m_us_gd_tang_giam_tai_san.dcID_NGUOI_DUYET = Person.get_user_id();

        m_us_gd_tang_giam_tai_san.Insert();

        // Phần cập nhật thông tin cho DM
        if (m_cbo_ly_do_thay_doi.SelectedValue == ID_LY_DO_TANG_GIAM_TAI_SAN.DIEU_CHUYEN.ToString())
        {
            update_thong_tin_tai_san(v_us_dm_oto);
        }

        if (m_cbo_ly_do_thay_doi.SelectedValue == ID_LY_DO_TANG_GIAM_TAI_SAN.THANH_LY.ToString())
        {
            v_us_dm_oto.dcID_TRANG_THAI = ID_TRANG_THAI_OTO.DA_THANH_LY;
            v_us_dm_oto.Update();
        }
        if (m_cbo_ly_do_thay_doi.SelectedValue == ID_LY_DO_TANG_GIAM_TAI_SAN.DIEU_CHUYEN.ToString())
        {
            v_us_dm_oto.dcID_TRANG_THAI = ID_TRANG_THAI_OTO.DA_DIEU_CHUYEN;
            v_us_dm_oto.Update();
        }
        if (m_cbo_ly_do_thay_doi.SelectedValue == ID_LY_DO_TANG_GIAM_TAI_SAN.TRANG_CAP_MUA_MOI.ToString())
        {
            v_us_dm_oto.dcID_TRANG_THAI = ID_TRANG_THAI_OTO.DANG_SU_DUNG;
            v_us_dm_oto.Update();
        }
        m_lbl_message.Text = "Cập nhật thành công";
        //lay Ma Phieu bo xuong o Tu Khoa
        m_txt_tu_khoa.Text = m_us_gd_tang_giam_tai_san.strMA_PHIEU;
    }