private void load_cbo_ten_pb()
 {
     m_trang_thai = false;
     //US_DM_PHONG_BAN v_us = new US_DM_PHONG_BAN();
     //DS_DM_PHONG_BAN v_ds = new DS_DM_PHONG_BAN();
     //v_us.FillDataset(v_ds, "order by ten_phong_ban");
     //m_cbo_ten_pb.DataSource = v_ds.DM_PHONG_BAN;
     //m_cbo_ten_pb.ValueMember = DM_PHONG_BAN.ID;
     //m_cbo_ten_pb.DisplayMember = DM_PHONG_BAN.TEN_PHONG_BAN;
     //DataRow v_dr = v_ds.DM_PHONG_BAN.NewRow();
     //v_dr[DM_PHONG_BAN.ID] = -1;
     //v_dr[DM_PHONG_BAN.MA_PHONG_BAN] = "Tất cả";
     //v_dr[DM_PHONG_BAN.TEN_PHONG_BAN] = "Tất cả";
     //v_ds.DM_PHONG_BAN.Rows.InsertAt(v_dr, 0);
     //m_cbo_ten_pb.SelectedIndex = 0;
     US_DM_PHAP_NHAN v_us = new US_DM_PHAP_NHAN();
     DS_DM_PHAP_NHAN v_ds = new DS_DM_PHAP_NHAN();
     v_us.FillDataset(v_ds);
     m_cbo_ten_pb.DataSource = v_ds.DM_PHAP_NHAN;
     m_cbo_ten_pb.ValueMember = DM_PHAP_NHAN.ID;
     m_cbo_ten_pb.DisplayMember = DM_PHAP_NHAN.TEN_PHAP_NHAN;
     DataRow v_dr = v_ds.DM_PHAP_NHAN.NewRow();
     v_dr[DM_PHAP_NHAN.ID] = -1;
     v_dr[DM_PHAP_NHAN.MA_PHAP_NHAN] = "Tất cả";
     v_dr[DM_PHAP_NHAN.TEN_PHAP_NHAN] = "Tất cả";
     v_ds.DM_PHAP_NHAN.Rows.InsertAt(v_dr, 0);
     m_cbo_ten_pb.SelectedIndex = 0;
        m_trang_thai = true;
 }
        private void load_data_to_cbo_phap_nhan()
        {
            US_DM_PHAP_NHAN v_us = new US_DM_PHAP_NHAN();
            DS_DM_PHAP_NHAN v_ds = new DS_DM_PHAP_NHAN();
            v_us.FillDataset(v_ds, "order by " + DM_PHAP_NHAN.MA_PHAP_NHAN);

            DataRow v_dr = v_ds.Tables[0].NewRow();
            v_dr[DM_PHAP_NHAN.ID] = -1;
            v_dr[DM_PHAP_NHAN.GHI_CHU] = "";
            v_dr[DM_PHAP_NHAN.MA_PHAP_NHAN] = "Topica";
            v_dr[DM_PHAP_NHAN.TEN_PHAP_NHAN] = "Topica";
            v_ds.Tables[0].Rows.InsertAt(v_dr, 0);
            v_ds.AcceptChanges();

            m_cbo_phap_nhan.DisplayMember = DM_PHAP_NHAN.MA_PHAP_NHAN;
            m_cbo_phap_nhan.ValueMember = DM_PHAP_NHAN.ID;
            m_cbo_phap_nhan.DataSource = v_ds.DM_PHAP_NHAN;
        }
 private void load_data_2_cbo_phap_nhan()
 {
     US_DM_PHAP_NHAN v_us = new US_DM_PHAP_NHAN();
     DS_DM_PHAP_NHAN v_ds = new DS_DM_PHAP_NHAN();
     v_us.FillDataset(v_ds);
     m_cbo_phap_nhan.DataSource = v_ds.DM_PHAP_NHAN;
     m_cbo_phap_nhan.ValueMember = DM_PHAP_NHAN.ID;
     m_cbo_phap_nhan.DisplayMember = DM_PHAP_NHAN.TEN_PHAP_NHAN;
     DataRow v_dr = v_ds.DM_PHAP_NHAN.NewRow();
     v_dr[DM_PHAP_NHAN.ID] = -1;
     v_dr[DM_PHAP_NHAN.MA_PHAP_NHAN] = "";
     v_dr[DM_PHAP_NHAN.TEN_PHAP_NHAN] = "Tất cả";
     v_dr[DM_PHAP_NHAN.GHI_CHU] = " ";
     v_ds.DM_PHAP_NHAN.Rows.InsertAt(v_dr, 0);
     m_cbo_phap_nhan.SelectedIndex = 0;
 }
        private IDictionary get_mapping_col_ten_phong_ban()
        {
            Hashtable v_hst = new Hashtable();

            US_DM_PHAP_NHAN v_us_dm_phap_nhan = new US_DM_PHAP_NHAN();
            DS_DM_PHAP_NHAN v_ds_dm_phap_nhan = new DS_DM_PHAP_NHAN();

            v_us_dm_phap_nhan.FillDataset(v_ds_dm_phap_nhan);

            foreach (DataRow v_dr in v_ds_dm_phap_nhan.DM_PHAP_NHAN.Rows)
            {
                v_hst.Add(v_dr[DM_PHAP_NHAN.ID], v_dr[DM_PHAP_NHAN.TEN_PHAP_NHAN]);
            }
            return v_hst;
        }
        private void load_data_phap_nhan()
        {
            try
            {
                US_DM_PHAP_NHAN v_us_dm_phap_nhan = new US_DM_PHAP_NHAN();
                DS_DM_PHAP_NHAN v_ds_dm_phap_nhan = new DS_DM_PHAP_NHAN();
                v_us_dm_phap_nhan.FillDataset(v_ds_dm_phap_nhan," order by ma_phap_nhan");

                m_cbx_phap_nhan.DataSource = v_ds_dm_phap_nhan.DM_PHAP_NHAN;
                m_cbx_phap_nhan.DisplayMember = DM_PHAP_NHAN.MA_PHAP_NHAN;
                m_cbx_phap_nhan.ValueMember = DM_PHAP_NHAN.ID;
                m_cbx_phap_nhan.SelectedValue = "5";
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }
        private void load_data_nguoi_nhan_ban_luu()
        {
            try
            {
                US_V_DM_PHONG_BAN_PHAP_NHAN v_us_dm_phong_ban = new US_V_DM_PHONG_BAN_PHAP_NHAN();
                DS_V_DM_PHONG_BAN_PHAP_NHAN v_ds_dm_phong_ban = new DS_V_DM_PHONG_BAN_PHAP_NHAN();
                m_cbx_ban_luu.DisplayMember = V_DM_PHONG_BAN_PHAP_NHAN.MA_PHONG_BAN;
                m_cbx_ban_luu.ValueMember = V_DM_PHONG_BAN_PHAP_NHAN.ID_PHONG_BAN;

                US_DM_PHAP_NHAN v_us_dm_phap_nhan = new US_DM_PHAP_NHAN(CIPConvert.ToDecimal(m_cbx_phap_nhan.SelectedValue));
                if (v_us_dm_phap_nhan.strMA_PHAP_NHAN == "TPE" )
                {
                    v_us_dm_phong_ban.FillDataset(v_ds_dm_phong_ban, "where id_phap_nhan=" +m_cbx_phap_nhan.SelectedValue + " order by ma_phong_ban");//5 la id EDT
                    m_cbx_ban_luu.DataSource = v_ds_dm_phong_ban.v_DM_PHONG_BAN_PHAP_NHAN;
                }
                else
                {
                    v_us_dm_phong_ban.FillDataset(v_ds_dm_phong_ban, "where id_phap_nhan=5 order by ma_phong_ban");//5 la id EDT
                    m_cbx_ban_luu.DataSource = v_ds_dm_phong_ban.v_DM_PHONG_BAN_PHAP_NHAN;
                }
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }
        public void display(decimal ip_id_phap_nhan, DateTime ip_tu_ngay, DateTime ip_den_ngay)
        {
            m_obj_trans = get_trans_object(m_fg);
            //Lay ten Phap nhan
            DS_DM_PHAP_NHAN v_ds_dm_phap_nhan = new DS_DM_PHAP_NHAN();
            US_DM_PHAP_NHAN v_us_dm_phap_nhan = new US_DM_PHAP_NHAN();
            v_us_dm_phap_nhan.FillDataset(v_ds_dm_phap_nhan, "where id =" +ip_id_phap_nhan);
            m_lbl_ten_phap_nhan.Text = v_ds_dm_phap_nhan.DM_PHAP_NHAN.Rows[0]["TEN_PHAP_NHAN"].ToString();

            DS_RPT_CHI_TIET_CHI_PHI_PHAP_NHAN v_ds_rpt_chi_tiet = new DS_RPT_CHI_TIET_CHI_PHI_PHAP_NHAN();
            US_RPT_CHI_TIET_CHI_PHI_PHAP_NHAN v_us_rpt_chi_tiet = new US_RPT_CHI_TIET_CHI_PHI_PHAP_NHAN();
            v_us_rpt_chi_tiet.fillDatasetChiPhiPhapNhan(v_ds_rpt_chi_tiet, ip_id_phap_nhan, ip_tu_ngay, ip_den_ngay);
            m_fg.Redraw = true;
            CGridUtils.Dataset2C1Grid(v_ds_rpt_chi_tiet, m_fg, m_obj_trans);
            //Lay tong tien

            m_fg.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Sum // chỗ này dùng hàm count tức là để đếm, có thể dùng các hàm khác thay thế
             , 0
             , (int)e_col_Number.TEN_PHONG_BAN // chỗ này là tên trường mà mình nhóm
             , (int)e_col_Number.SO_TIEN // chỗ này là tên trường mà mình Count
             , "{0}"
             );
            m_fg.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Sum // chỗ này dùng hàm count tức là để đếm, có thể dùng các hàm khác thay thế
             , 0
             , (int)e_col_Number.TEN_PHONG_BAN // chỗ này là tên trường mà mình nhóm
             , (int)e_col_Number.TIEN_PN // chỗ này là tên trường mà mình Count
             , "{0}"
             );
            decimal v_tong_tien = 0;
            for(int v_i_row = m_fg.Rows.Fixed; v_i_row < m_fg.Rows.Count - 1; v_i_row++) {
                if(m_fg.Rows[v_i_row].IsNode == true)
                    if(m_fg.Rows[v_i_row][(int)e_col_Number.TIEN_PN] != null) {
                        v_tong_tien = v_tong_tien + CIPConvert.ToDecimal(m_fg.Rows[v_i_row][(int)e_col_Number.TIEN_PN]);
                    }

            }
            m_lbl_tong_tien.Text = CIPConvert.ToStr(v_tong_tien, "#,###")+ " (VNĐ)";

            //for(int v_i_row = m_fg.Rows.Fixed; v_i_row < m_fg.Rows.Count - 1; v_i_row++) {
            //    if(m_fg.Rows[v_i_row].IsNode == true) {
            //        US_DM_PHONG_BAN v_us_dm_phong_ban = new US_DM_PHONG_BAN();
            //        DS_DM_PHONG_BAN v_ds_dm_phong_ban = new DS_DM_PHONG_BAN();
            //        v_us_dm_phong_ban.FillDataset(v_ds_dm_phong_ban, "where TEN_PHONG_BAN = N'" + m_fg.Rows[v_i_row].Node.Data +"'");

            //        DS_DM_PHONG_BAN_PHAP_NHAN v_ds = new DS_DM_PHONG_BAN_PHAP_NHAN();
            //        US_DM_PHONG_BAN_PHAP_NHAN v_us = new US_DM_PHONG_BAN_PHAP_NHAN();
            //        v_us.timTyTrongTrungTam(v_ds, ip_id_phap_nhan, CIPConvert.ToDecimal(v_ds_dm_phong_ban.DM_PHONG_BAN[0]["ID"]));
            //        m_fg.Rows[v_i_row][(int)e_col_Number.TY_TRONG] = v_ds.DM_PHONG_BAN_PHAP_NHAN[0]["TY_TRONG"];
            //        //m_fg.Rows[v_i_row][(int)e_col_Number.TIEN_PN] = v_ds.DM_PHONG_BAN_PHAP_NHAN[0]["TY_TRONG"] * m_fg.Rows[v_i_row]["SO_TIEN"];
            //    }

            //}
            //m_fg.Subtotal(C1.Win.C1FlexGrid.AggregateEnum.Sum
            //    , 0
            //    , (int)e_col_Number.NGAY_GUI
            //    , (int)e_col_Number.SO_BILL
            //    , "{0}"
            //    );
            m_fg.Redraw = true;
            this.ShowDialog();
        }
 private void load_cbo_phap_nhan()
 {
     flag = false;
     US_DM_PHAP_NHAN v_us = new US_DM_PHAP_NHAN();
     DS_DM_PHAP_NHAN v_ds = new DS_DM_PHAP_NHAN();
     v_us.FillDataset(v_ds);
     m_cbo_phap_nhan.DataSource = v_ds.DM_PHAP_NHAN;
     m_cbo_phap_nhan.ValueMember = DM_PHAP_NHAN.ID;
     m_cbo_phap_nhan.DisplayMember = DM_PHAP_NHAN.TEN_PHAP_NHAN;
     DataRow v_dr = v_ds.Tables[0].NewRow();
     v_dr[DM_PHAP_NHAN.ID] = -1;
     v_dr[DM_PHAP_NHAN.MA_PHAP_NHAN] = "";
     v_dr[DM_PHAP_NHAN.TEN_PHAP_NHAN] = "Tất cả";
     v_ds.DM_PHAP_NHAN.Rows.InsertAt(v_dr, 0);
     m_cbo_phap_nhan.SelectedIndex = 0;
     flag = true;
 }