Beispiel #1
0
    private void load_data_2_grid_search(string ip_str_ma_dot_tt, string ip_str_so_hd)
    {
        US_V_GD_THANH_TOAN v_us_gd_thanh_toan = new US_V_GD_THANH_TOAN();
        DS_V_GD_THANH_TOAN v_ds_gd_thanh_toan = new DS_V_GD_THANH_TOAN();
        decimal            v_dc_id_hdong      = get_id_by_so_hop_dong(ip_str_so_hd);

        if (v_dc_id_hdong == 0)
        {
            m_lbl_thong_bao.Visible         = true;
            m_lbl_thong_bao.Text            = "Không có thanh toán nào phù hợp";
            m_grv_danh_sach_du_toan.Visible = false;
            return;
        }
        v_us_gd_thanh_toan.FillDataset(v_ds_gd_thanh_toan, " WHERE SO_PHIEU_THANH_TOAN = '" + ip_str_ma_dot_tt + "' AND ID_HOP_DONG_KHUNG = " + v_dc_id_hdong);
        if (v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count == 0)
        {
            m_lbl_thong_bao.Visible = true;
            m_lbl_thong_bao.Text    = "Không có thanh toán nào phù hợp";
        }
        else
        {
            m_grv_danh_sach_du_toan.Visible = true;
        }
        m_grv_danh_sach_du_toan.DataSource = v_ds_gd_thanh_toan.V_GD_THANH_TOAN;
        m_grv_danh_sach_du_toan.DataBind();
    }
    // Hàm này kiểm tra
    // - Lớp môn có ứng với hợp đồng không?
    private void kiem_tra_toan_bo_thanh_toan_ung_hop_dong(decimal ip_dc_id_hop_dong_khung, string ip_str_ma_lop_mon)
    {
        US_V_GD_THANH_TOAN v_us_v_gd_tt = new US_V_GD_THANH_TOAN();
        DS_V_GD_THANH_TOAN v_ds_v_gd_tt = new DS_V_GD_THANH_TOAN();

        // lấy toàn bộ thanh toán của hợp đồng theo id_hop_dong
        v_us_v_gd_tt.FillDataset(v_ds_v_gd_tt, " WHERE ID_HOP_DONG_KHUNG=" + ip_dc_id_hop_dong_khung + " ORDER BY ID");
        // Nếu đã có thanh toán
        if (v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count > 0)
        {
            // kiểm tra xem đã thanh lý chưa
            // Sử dụng dòng cuối cùng, ứng với thanh toán cuối cùng của hd này
            // Nếu đã thanh lý, reference_code là null
            if (v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows[v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count - 1][V_GD_THANH_TOAN.REFERENCE_CODE].GetType() == typeof(DBNull))
            {
                string someScript;
                someScript = "<script language='javascript'>{ alert('Hợp đồng này đã được thanh lý!'); window.close(); }</script>";
                Page.ClientScript.RegisterStartupScript(this.GetType(), "oncheck", someScript);
                return;
            }
            // Nếu ko phải thanh lý mà là tạm ứng, kiểm tra số lần tạm ứng
            else
            {
                decimal v_dc_so_tien_da_tt   = 0;
                string  v_str_so_lan_tam_ung = cut_end_string(CIPConvert.ToStr(v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows[v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count - 1][V_GD_THANH_TOAN.REFERENCE_CODE]));
                v_dc_so_tien_da_tt  += CIPConvert.ToDecimal(v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows[v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count - 1][V_GD_THANH_TOAN.DA_THANH_TOAN]) + CIPConvert.ToDecimal(v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows[v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count - 1][V_GD_THANH_TOAN.TONG_TIEN_THANH_TOAN]);
                m_lbl_thong_bao.Text = "Hợp đồng này đã được tạm ứng " + v_str_so_lan_tam_ung + " lần. Số tiền đã thanh toán là: " + CIPConvert.ToStr(v_dc_so_tien_da_tt, "#,###");
            }
        }
        // Nếu số dòng ==0 nghĩa là chưa có thanh toán nào, ko thực hiện gì
    }
    private decimal get_so_tien_da_tt(decimal ip_dc_id_so_hd)
    {
        US_V_GD_THANH_TOAN v_us_v_gd_tt = new US_V_GD_THANH_TOAN();
        DS_V_GD_THANH_TOAN v_ds_v_gd_tt = new DS_V_GD_THANH_TOAN();

        v_us_v_gd_tt.FillDataset(v_ds_v_gd_tt, " WHERE ID_HOP_DONG_KHUNG =" + ip_dc_id_so_hd);
        return(CIPConvert.ToDecimal(v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows[0][V_GD_THANH_TOAN.DA_THANH_TOAN]));
    }
    private int get_the_number_of_payments_by_dot_tt(string ip_str_ma_dot_tt)
    {
        US_V_GD_THANH_TOAN v_us_v_gd_tt = new US_V_GD_THANH_TOAN();
        DS_V_GD_THANH_TOAN v_ds_v_gd_tt = new DS_V_GD_THANH_TOAN();

        v_us_v_gd_tt.FillDataset(v_ds_v_gd_tt, " WHERE SO_PHIEU_THANH_TOAN='" + ip_str_ma_dot_tt + "'");
        return(v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count);
    }
    // Check trạng thái các thanh toán  trong KHO nằm trong đợt thanh toán này
    // Nếu có các thanh toán đó thì ta cho nó vào 1 ds để xuất ra màn hình
    private bool check_trang_thai_cac_thanh_toan_cua_dot_tt_trong_kho(string ip_str_ma_dot_tt, ref DS_V_GD_THANH_TOAN ip_ds_gd_thanh_toan)
    {
        US_V_GD_THANH_TOAN v_us_v_gd_thanh_toan = new US_V_GD_THANH_TOAN();

        // Láy tất cả các thanh toán trong kho mà có description giống với mã đợt thanh toán hiện
        v_us_v_gd_thanh_toan.FillDataset(ip_ds_gd_thanh_toan, " WHERE SO_PHIEU_THANH_TOAN like '%KHO%' AND [DESCRIPTION] like N'%" + ip_str_ma_dot_tt + "%' AND ID_TRANG_THAI_THANH_TOAN = " + hdf_id_trang_thai_ngan_hang_chuyen_khoan_khong_thanh_cong.Value + " ORDER BY ID DESC");
        // Nếu ko có thanh toán nào phù hợp, nghĩa là ổn :)
        if (ip_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count == 0)
        {
            return(true);
        }
        return(false);
    }
    /// <summary>
    /// Hàm này kiểm tra trạng thái các thanh toán trong đợt thanh tóan (có cho đóng đợt thanh toán ko???). Cho đóng đợt thanh toán khi:
    /// + Khi tất cả các thanh toán có trong đợt đã ở trạng thái 5_DA_CO_XAC_NHAN_CUA_GIANG_VIEN
    /// + không có thanh toán nào của đợt này trong KHO có trạng thái: 3B_NGAN_HANG_CHUYEN_KHOAN_KHONG_THANH_CONG
    /// </summary>
    /// <param name="ip_str_ma_dot_tt">Mã của đợt thanh toán cần kiểm tra</param>
    private bool check_trang_thai_cac_thanh_toan_cua_dot_tt(string ip_str_ma_dot_tt)
    {
        // Check trạng thái các thanh toán trong đợt thanh toán
        US_V_GD_THANH_TOAN v_us_v_gd_thanh_toan = new US_V_GD_THANH_TOAN();
        DS_V_GD_THANH_TOAN v_ds_v_gd_thanh_toan = new DS_V_GD_THANH_TOAN();

        // Load các thanh toán có trạng thái khác với đã có xác nhận giảng viên
        v_us_v_gd_thanh_toan.FillDataset(v_ds_v_gd_thanh_toan, " WHERE SO_PHIEU_THANH_TOAN =N'" + ip_str_ma_dot_tt + "' AND ID_TRANG_THAI_THANH_TOAN <> " + hdf_id_trang_thai_da_co_xac_nhan_gv.Value + " ORDER BY ID");
        if (v_ds_v_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count > 0)
        {
            return(false);
        }
        return(true);
    }
Beispiel #7
0
 private void search_data_and_load_to_grid(string ip_str_so_phieu_tt)
 {
     try
     {
         m_lbl_loc_du_lieu.Text = "Danh sách bản kê các khoản thanh toán : " + m_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count + " hợp đồng";
         m_us_gd_thanh_toan.FillDataset(m_ds_gd_thanh_toan, " WHERE SO_PHIEU_THANH_TOAN='" + ip_str_so_phieu_tt + "'");
         if (m_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count == 0)
         {
             if (m_grv_danh_sach_du_toan.Visible == true)
             {
                 m_grv_danh_sach_du_toan.Visible = false;
             }
             return;
         }
         m_grv_danh_sach_du_toan.Visible    = true;
         m_grv_danh_sach_du_toan.DataSource = m_ds_gd_thanh_toan.V_GD_THANH_TOAN;
         m_grv_danh_sach_du_toan.DataBind();
     }
     catch (Exception v_e)
     {
         throw v_e;
     }
 }
 /// <summary>
 ///  Hàm này load các thanh toán chưa có xác nhận của giảng viên và bind lên lưới
 /// </summary>
 /// <param name="ip_str_ma_dot_tt">Mã đợt thanh toán</param>
 private void load_cac_thanh_toan_chua_duoc_xac_nhan_gv(string ip_str_ma_dot_tt)
 {
     m_us_gd_thanh_toan.FillDataset(m_ds_gd_thanh_toan, " WHERE SO_PHIEU_THANH_TOAN='" + ip_str_ma_dot_tt + "' AND ID_TRANG_THAI_THANH_TOAN <> " + hdf_id_trang_thai_da_co_xac_nhan_gv.Value + " ORDER BY ID DESC");
     if (m_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count == 0)
     {
         if (m_grv_danh_sach_du_toan.Visible == true)
         {
             m_grv_danh_sach_du_toan.Visible = false;
         }
         return;
     }
     m_grv_danh_sach_du_toan.Visible    = true;
     m_grv_danh_sach_du_toan.DataSource = m_ds_gd_thanh_toan.V_GD_THANH_TOAN;
     m_grv_danh_sach_du_toan.DataBind();
     m_grv_danh_sach_du_toan.Columns[0].Visible = true;
     m_lbl_loc_du_lieu.Text = "Danh sách các thanh toán chưa có xác nhận của giảng viên: " + m_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count + " thanh toán";
 }
    public decimal get_so_tien_da_thanh_toan(decimal ip_dc_id_hop_dong)
    {
        decimal v_dc_so_tien_da_tt = 0;

        m_us_v_gd_thanh_toan.FillDataset(m_v_ds_gd_thanh_toan, " WHERE ID_HOP_DONG_KHUNG=" + ip_dc_id_hop_dong + " AND REFERENCE_CODE IS NOT NULL");
        if (m_v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count == 0)
        {
            return(0);
        }
        else
        {
            foreach (DataRow dtr in m_v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows)
            {
                v_dc_so_tien_da_tt += CIPConvert.ToDecimal(dtr[V_GD_THANH_TOAN.TONG_TIEN_THANH_TOAN]);
            }
        }
        return(v_dc_so_tien_da_tt);
    }
    private decimal get_so_tien_da_thanh_toan_update(decimal ip_dc_id_hop_dong_khung)
    {
        US_V_GD_THANH_TOAN v_us_v_gd_tt = new US_V_GD_THANH_TOAN();
        DS_V_GD_THANH_TOAN v_ds_v_gd_tt = new DS_V_GD_THANH_TOAN();

        // lấy toàn bộ thanh toán của hợp đồng theo id_hop_dong
        v_us_v_gd_tt.FillDataset(v_ds_v_gd_tt, " WHERE ID_HOP_DONG_KHUNG=" + ip_dc_id_hop_dong_khung + " ORDER BY ID");
        // Nếu đã có thanh toán
        if (v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count > 0)
        {
            decimal v_dc_so_tien_da_tt = 0;
            //string v_str_so_lan_tam_ung = cut_end_string(CIPConvert.ToStr(v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows[v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count - 1][V_GD_THANH_TOAN.REFERENCE_CODE]));
            v_dc_so_tien_da_tt += CIPConvert.ToDecimal(v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows[v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count - 1][V_GD_THANH_TOAN.DA_THANH_TOAN]);
            return(v_dc_so_tien_da_tt);
        }
        else
        {
            return(0);
        }
    }
    // Kiểm tra hợp đồng đã được thanh lý chưa?
    private bool check_thanh_ly(decimal ip_dc_id_hop_dong_khung)
    {
        US_V_GD_THANH_TOAN v_us_v_gd_tt = new US_V_GD_THANH_TOAN();
        DS_V_GD_THANH_TOAN v_ds_v_gd_tt = new DS_V_GD_THANH_TOAN();

        // lấy toàn bộ thanh toán của hợp đồng theo id_hop_dong
        v_us_v_gd_tt.FillDataset(v_ds_v_gd_tt, " WHERE ID_HOP_DONG_KHUNG=" + ip_dc_id_hop_dong_khung + " ORDER BY ID");
        // Nếu đã có thanh toán
        if (v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count > 0)
        {
            // kiểm tra xem đã thanh lý chưa
            // Sử dụng dòng cuối cùng, ứng với thanh toán cuối cùng của hd này
            // Nếu đã thanh lý, reference_code là null
            if (v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows[v_ds_v_gd_tt.V_GD_THANH_TOAN.Rows.Count - 1][V_GD_THANH_TOAN.REFERENCE_CODE].GetType() == typeof(DBNull))
            {
                return(false);    // Nghĩa là đã được thanh lý
            }
        }
        return(true);    // Chưa đc thanh lý
    }
Beispiel #12
0
 private void load_data_2_grid(string ip_str_ma_dot_tt)
 {
     if (ip_str_ma_dot_tt == "")
     {
         m_lbl_thong_bao.Visible = true;
         m_lbl_thong_bao.Text    = "Chưa tạo Đợt thanh toán";
         return;
     }
     else
     {
         US_V_GD_THANH_TOAN v_us_gd_thanh_toan = new US_V_GD_THANH_TOAN();
         DS_V_GD_THANH_TOAN v_ds_gd_thanh_toan = new DS_V_GD_THANH_TOAN();
         // Số phiếu thanh toán là mã đợt thanh toán
         v_us_gd_thanh_toan.FillDataset(v_ds_gd_thanh_toan, " WHERE SO_PHIEU_THANH_TOAN = '" + ip_str_ma_dot_tt + "'");
         if (v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count == 0)
         {
             m_lbl_thong_bao.Visible = true;
             m_lbl_thong_bao.Text    = "Chưa có Thanh toán nào ứng với Đợt thanh toán này";
         }
         m_grv_danh_sach_du_toan.DataSource = v_ds_gd_thanh_toan.V_GD_THANH_TOAN;
         m_grv_danh_sach_du_toan.DataBind();
     }
 }
 private void load_data_2_grid(string ip_str_ma_dot_tt)
 {
     if (ip_str_ma_dot_tt == "")
     {
         m_lbl_thong_bao.Visible = true;
         m_lbl_thong_bao.Text    = "Chưa tạo Đợt thanh toán";
         return;
     }
     else
     {
         US_V_GD_THANH_TOAN v_us_gd_thanh_toan = new US_V_GD_THANH_TOAN();
         DS_V_GD_THANH_TOAN v_ds_gd_thanh_toan = new DS_V_GD_THANH_TOAN();
         // Số phiếu thanh toán là mã đợt thanh toán
         v_us_gd_thanh_toan.FillDataset(v_ds_gd_thanh_toan, " WHERE SO_PHIEU_THANH_TOAN = N'" + ip_str_ma_dot_tt + "' AND ID_TRANG_THAI_THANH_TOAN <> " + hdf_id_trang_thai_chung_tu_chua_duoc_thanh_toan.Value + " ORDER BY ID DESC");
         if (v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count == 0)
         {
             m_lbl_thong_bao.Visible = true;
             m_lbl_thong_bao.Text    = "Chưa có Thanh toán nào ứng với Đợt thanh toán này";
         }
         m_grv_danh_sach_du_toan.DataSource = v_ds_gd_thanh_toan.V_GD_THANH_TOAN;
         m_grv_danh_sach_du_toan.DataBind();
         m_lbl_danh_sach_chung_tu_ton_dong.Text = "Danh sách các chứng từ tồn đọng: " + v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count + " chứng từ";
     }
 }
    private void load_data_2_grid_lich_su(decimal ip_dc_id_hop_dong, string ip_str_ma_lop_mon)
    {
        US_V_GD_THANH_TOAN v_us_gd_thanh_toan = new US_V_GD_THANH_TOAN();
        DS_V_GD_THANH_TOAN v_ds_gd_thanh_toan = new DS_V_GD_THANH_TOAN();

        v_us_gd_thanh_toan.FillDataset(v_ds_gd_thanh_toan, " WHERE ID_HOP_DONG_KHUNG =" + ip_dc_id_hop_dong + " AND REFERENCE_CODE = '" + ip_str_ma_lop_mon + "'");
        if (v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count == 0)
        {
            m_lbl_thong_bao.Text = "Chưa có thanh toán nào ứng với lớp môn và hợp đồng này";
            return;
        }
        m_grv_dm_danh_sach_hop_dong_khung.DataSource = v_ds_gd_thanh_toan.V_GD_THANH_TOAN;
        m_grv_dm_danh_sach_hop_dong_khung.DataBind();
        if (v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count > 0)
        {
            decimal v_dc_sum = 0;
            for (int i = 0; i < v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows.Count; i++)
            {
                v_dc_sum += CIPConvert.ToDecimal(v_ds_gd_thanh_toan.V_GD_THANH_TOAN.Rows[i][V_GD_THANH_TOAN.TONG_TIEN_THANH_TOAN]);
            }
            //string v_str_da_tt =
            m_grv_dm_danh_sach_hop_dong_khung.FooterRow.Cells[8].Text = CIPConvert.ToStr(v_dc_sum, "#,###");
        }
    }