protected void btnThem_Click(object sender, EventArgs e)
 {
     DonViDTO dvdto = new DonViDTO();
     DonViBHDAO dvdao = new DonViBHDAO();
     try
     {
          bool kq = dvdao.KiemTraMaHoa(txtMaHoa.Text);
          if (kq == true)
              txtThongBaoLoiMaHoa.Text = "Đã tồn tại mã hóa cho đơn vị khác !";
          else
          {
              dvdto.MaHoa = txtMaHoa.Text.Trim();
              dvdto.TenDonVi = txtTendonvi.Text.Trim();
              dvdto.Id_NhaBH = int.Parse(drCTYTong.SelectedItem.Value.ToString());
              dvdto.DiaChi = txtDiaChi.Text.Trim();
              dvdto.DienThoai = txtDienThoai.Text.Trim();
              dvdto.Fax = txtFax.Text.Trim();
              dvdto.WebSite = txtWebsite.Text.Trim();
              dvdto.MaSoThue = txtMaSoThue.Text;
              //dvdto.MaNguoiDaiDien = int.Parse(drNguoiDaiDien.SelectedItem.Value.ToString());
              dvdao.DonViMoi(dvdto);
              txtThongBaoLoiMaHoa.Text = "";
              //txtThemThanhCong.Text = "Succed!";
              //Response.Redirect("~/pages/Claim.aspx");
              Response.Write("<script>alert('Succeed!');</script>");
              loadDVNBH();
          }
     }
     catch (Exception ex)
     {
         Response.Write(ex.Message);
     }
 }
 protected void grDS_RowUpdating(object sender, GridViewUpdateEventArgs e)
 {
     GridViewRow row = grDS.Rows[e.RowIndex];
     TextBox txtmahoa = row.Cells[1].Controls[0] as TextBox;
     TextBox txttendonvi = row.Cells[2].Controls[0] as TextBox;
     TextBox txtdiachi = row.Cells[3].Controls[0] as TextBox;
     TextBox txtmst = row.Cells[4].Controls[0] as TextBox;
     int id=Int32.Parse(grDS.DataKeys[e.RowIndex].Value.ToString());
     DonViDTO dv = new DonViDTO();
     dv.Id_DonVi = id;
     dv.TenDonVi = txttendonvi.Text;
     dv.DiaChi = txtdiachi.Text;
     dv.MaHoa = txtmahoa.Text;
     dv.MaSoThue = txtmst.Text;
     DonViBHDAO dvdao = new DonViBHDAO();
     bool up=dvdao.DonViUpdate(dv);
     if (up == true)
     {
         e.Cancel = true;
         grDS.EditIndex = -1;
         int ma = int.Parse(drNBH.SelectedItem.Value.ToString());
         loadDS(ma);
     }
     else
         Response.Write("");
 }
 protected void drNBH_SelectedIndexChanged(object sender, EventArgs e)
 {
     DonViBHDAO dvbhdao = new DonViBHDAO();
     int maNhaBH = int.Parse(drNBH.SelectedItem.Value.ToString());
     drDV.DataSource = dvbhdao.DSDonViBaoHiem(maNhaBH);
     drDV.DataValueField = "ID_DonVi";
     drDV.DataTextField = "TenDonVi";
     drDV.DataBind();
 }
        void load_DonViBaoHiem(int maNhaBH)
        {
            if (!this.IsPostBack)
            {

                DonViBHDAO dvbhdao = new DonViBHDAO();
                drDVBH.DataSource = dvbhdao.DSDonViBaoHiem(maNhaBH);
                drDVBH.DataValueField = "ID_DonVi";
                drDVBH.DataTextField = "TenDonVi";
                drDVBH.DataBind();
            }
        }
        void load_DonViBaoHiem(int maNhaBH)
        {
            if (!this.IsPostBack)
            {

                DonViBHDAO dvbhdao = new DonViBHDAO();
                DataTable dt = new DataTable();
                dt= dvbhdao.DSDonViBaoHiem(maNhaBH);
                if (dt.Rows.Count > 0)
                {
                    drDV.DataSource = dt;
                    drDV.DataValueField = "ID_DonVi";
                    drDV.DataTextField = "TenDonVi";
                    drDV.DataBind();
                }
            }
        }
 protected void drInsurer_SelectedIndexChanged(object sender, EventArgs e)
 {
     //if (this.IsPostBack)
         //{
         DonViBHDAO dvbhdao = new DonViBHDAO();
         int maNhaBH = int.Parse(drInsurer.SelectedItem.Value.ToString());
         if (maNhaBH != 0)
         {
             DataTable ds = new DataTable();
             ds = dvbhdao.DSDonViBaoHiem(maNhaBH);
             drSubsidiary.DataSource = ds;
             drSubsidiary.DataValueField = "ID_DonVi";
             drSubsidiary.DataTextField = "TenDonVi";
             drSubsidiary.DataBind();
         }
     //}
 }
 public static string[] LayDSGDV(string prefixText, int count)
 {
     DonViBHDAO dvdao = new DonViBHDAO();
     List<string> productList = new List<string>();
     DataTable dt = new DataTable();
     dt = dvdao.DSAllDonVi();
     if (dt.Rows.Count > 0)
     {
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             DataRow dr = dt.Rows[i];
             productList.Add(dr[1].ToString());
         }
     }
     var list = from p in productList
                where p.ToLower().Contains(prefixText.ToLower())
                select p;
     string[] prefixTextArray = list.ToArray<string>();
     return prefixTextArray;
 }
Beispiel #8
0
 void load_DonViBaoHiem(int maNhaBH)
 {
     DonViBHDAO dvbhdao = new DonViBHDAO();
     drSubsidiary.DataSource = dvbhdao.DSDonViBaoHiem(maNhaBH);
     drSubsidiary.DataValueField = "ID_DonVi";
     drSubsidiary.DataTextField = "TenDonVi";
     drSubsidiary.DataBind();
 }
 void load_Grid()
 {
     DonViBHDAO dvbhdao = new DonViBHDAO();
     int maNhaBH = int.Parse(drBH.SelectedItem.Value.ToString());
     if (maNhaBH > 0)
     {
         DataTable dt = new DataTable();
         dt = dvbhdao.DSDonViBaoHiem(maNhaBH);
         if (dt.Rows.Count > 0)
         {
             drDV.DataSource = dt;
             drDV.DataValueField = "ID_DonVi";
             drDV.DataTextField = "TenDonVi";
             drDV.DataBind();
         }
     }
 }
 void loadDRDV(int ma)
 {
     DonViBHDAO dv = new DonViBHDAO();
     drDonvi.DataSource = dv.DSDonViBaoHiem(ma);
     drDonvi.DataValueField = "ID_DonVi";
     drDonvi.DataTextField = "TenDonVi";
     drDonvi.DataBind();
 }
 protected void drNBH_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (this.IsPostBack)
     {
         DonViBHDAO dv = new DonViBHDAO();
         int ma = int.Parse(drNBH.SelectedItem.Value.ToString());
         if (ma != 0)
         {
             drDonvi.DataSource = dv.DSDonViBaoHiem(ma);
             drDonvi.DataValueField = "ID_DonVi";
             drDonvi.DataTextField = "TenDonVi";
             drDonvi.DataBind();
         }
     }
 }