private void us_object2grid(US_V_GD_DE_XUAT i_us
     , int i_grid_row)
 {
     DataRow v_dr = (DataRow)m_grv_de_xuat.Rows[i_grid_row].UserData;
     i_us.Me2DataRow(v_dr);
     m_obj_trans.DataRow2GridRow(v_dr, i_grid_row);
 }
 private void grid2us_object(US_V_GD_DE_XUAT i_us
     , int i_grid_row)
 {
     DataRow v_dr;
     v_dr = (DataRow)m_grv_de_xuat.Rows[i_grid_row].UserData;
     m_obj_trans.GridRow2DataRow(i_grid_row, v_dr);
     i_us.DataRow2Me(v_dr);
 }
 private void us_obj_2_form(US_V_GD_DE_XUAT ip_us_v)
 {
     m_us.dcID = ip_us_v.dcID;
     m_cbo_trung_tam.SelectedValue = ip_us_v.dcID_PHONG_BAN;
     m_txt_so_tien.Text = CIPConvert.ToStr(ip_us_v.dcSO_TIEN, "#,##0");
     m_txt_ghi_chu.Text = ip_us_v.strGHI_CHU;
     m_cbo_loai_de_xuat.Text = ip_us_v.strLOAI_DE_XUAT;
     m_dtp_thang.Text = ip_us_v.datTHANG_AP_DUNG.ToString("MM/yyyy");
     if (ip_us_v.strLINK != null || ip_us_v.strLINK != "")
     {
         m_lbl_file_name.Text = ip_us_v.strLINK;
     }
     else
         m_lbl_file_name.Text = "Hiện tại chưa có file đính kèm";
 }
 public void display_for_update(US_V_GD_DE_XUAT ip_us_v)
 {
     m_e_form_mode = DataEntryFormMode.UpdateDataState;
     us_obj_2_form(ip_us_v);
     this.ShowDialog();
 }
    private void load_ma_don_hang_title()
    {
        US_GD_DON_DAT_HANG v_us = new US_GD_DON_DAT_HANG();
        DS_GD_DON_DAT_HANG v_ds = new DS_GD_DON_DAT_HANG();
        US_V_GD_DE_XUAT v_us_de_xuat = new US_V_GD_DE_XUAT();
        DS_V_GD_DE_XUAT v_ds_de_xuat = new DS_V_GD_DE_XUAT();
        update_tong_tien_don_hang(CIPConvert.ToDecimal(m_hdf_id_don_hang.Value));
        v_us.FillDataset(v_ds, "where id=" + CIPConvert.ToDecimal(m_hdf_id_don_hang.Value));
        m_lbl_title_ma_don_hang.Text = "Nhập chi tiết đơn hàng ";
        m_lbl_ma_don_hang_de.Text = v_ds.Tables[0].Rows[0]["MA"].ToString();
        m_lbl_ma_don_hang_de.Visible = true;
        m_lbl_MP.Visible = true;

        decimal v_id_phong_ban = CIPConvert.ToDecimal(m_hdf_id_trung_tam.Value);
        decimal v_ti_le_vuot;
        decimal tien_de_xuat;
        decimal tong_tien;
        decimal dinh_muc;
        US_RPT_GD_DON_DAT_HANG_DINH_MUC v_us_don_hang = new US_RPT_GD_DON_DAT_HANG_DINH_MUC();
        DS_RPT_GD_DON_DAT_HANG_DINH_MUC v_ds_don_hang = new DS_RPT_GD_DON_DAT_HANG_DINH_MUC();
        v_us_don_hang.FillDS_don_hang_dinh_muc(v_ds_don_hang, v_id_phong_ban);
        m_lbl_pop_lan.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["LAN"],"#,###");
        DateTime v_dat_ngay = (DateTime)v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["NGAY_DAT_HANG"];
        m_lbl_pop_ngay.Text = v_dat_ngay.ToString("dd/MM/yyyy");
        m_lbl_pop_tong_tien.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"],"#,###") + "  (VNĐ)";
        m_lbl_pop_dinh_muc.Text = CIPConvert.ToStr(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"], "#,###") + "  (VNĐ)";
        // tính tỉ lệ vượt
        v_us_de_xuat.FillDSLayDeXuat(v_ds_de_xuat, v_dat_ngay, v_id_phong_ban);
        if(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"] != "" || v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"] != null)
            tong_tien = CIPConvert.ToDecimal(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["GIA_TRI_DA_VAT"]);
        else tong_tien = 0;
        if(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"] != "" || v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"] != null)
            dinh_muc = CIPConvert.ToDecimal(v_ds_don_hang.RPT_GD_DON_DAT_HANG_DINH_MUC.Rows[0]["DINH_MUC"]);
        else dinh_muc = 0;
        if(dinh_muc > 0)
        {
                if (v_ds_de_xuat.Tables[0].Rows.Count > 0)
                {
                    tien_de_xuat = CIPConvert.ToDecimal(v_ds_de_xuat.Tables[0].Rows[0]["SO_TIEN"]);

                     v_ti_le_vuot = ((tong_tien - tien_de_xuat - dinh_muc) / dinh_muc)*100;
                    if (v_ti_le_vuot > 0)
                     m_lbl_pop_ti_le_vuot.Text = CIPConvert.ToStr(v_ti_le_vuot,".#") + " (%)";
                    else m_lbl_pop_ti_le_vuot.Text = "0 (%)";
                }
                else
                {
                    v_ti_le_vuot = ((tong_tien - dinh_muc) / dinh_muc)*100;
                    if(v_ti_le_vuot > 0)
                        m_lbl_pop_ti_le_vuot.Text = CIPConvert.ToStr(v_ti_le_vuot, ".#") + " (%)";
                    else m_lbl_pop_ti_le_vuot.Text = "0 (%)";
                }
        }
        else m_lbl_pop_ti_le_vuot.Text = "Chưa có định mức";
    }