protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         //serviceCSKHCMIS.Service_CSKHCMIS ob = new Service_CSKHCMIS();
         CSKH_CMIS.Service_CSKHCMIS ob = new CSKH_CMIS.Service_CSKHCMIS();
         DataSet ds = ob.find_KHANG("CMIS2_VP", "PA25VY", "chung", "", "");
         //DataSet ds = ob.Get_HDONG_by_KHANG("SONLA", "PA15TX", "PA15TX0006309");
         GridView1.DataSource = ds;
         GridView1.DataBind();
     }
     catch (Exception ex) { Response.Write(ex.Message); }
 }
 private void Load_DonVi()
 {
     try
     {
         string url = Request.Url.Host;
         lbPC.Text = url.Substring(2, url.IndexOf('.') - 2).ToUpper();
         CSKH_CMIS.Service_CSKHCMIS ob = new CSKH_CMIS.Service_CSKHCMIS();
         DataSet ds = ob.Get_Dienluc(lbPC.Text);
         ddDonViQL.DataSource = ds;
         ddDonViQL.DataBind();
         lbError.Text = "";
     }
     catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình kết nối đến máy chủ. " + ex.Message; }
 }
        protected void Show_ThongTin(int rowID)
        {
            try
            {
                lbMaKH.Text = gvKhachHang.Rows[rowID].Cells[1].Text;
                lbDonVi.Text = gvKhachHang.Rows[rowID].Cells[4].Text;

                CSKH_CMIS.Service_CSKHCMIS ob = new CSKH_CMIS.Service_CSKHCMIS();
                DataSet ds = ob.Get_HDONG_by_KHANG(lbPC.Text, lbDonVi.Text, lbMaKH.Text);
                lbTenKH.Text = ds.Tables[0].Rows[0][2].ToString();
                lbDiaChi.Text = ds.Tables[0].Rows[0][3].ToString();
                lbHopDong.Text = ds.Tables[0].Rows[0][4].ToString();
                lbNgayKy.Text = DateTime.Parse(ds.Tables[0].Rows[0][5].ToString()).ToString("dd/MM/yyyy");
                lbGiaHan.Text = ds.Tables[0].Rows[0][6].ToString();
                //lbSoHo.Text = ds.Tables[0].Rows[0][7].ToString();
                lbDienThoai.Text = ds.Tables[0].Rows[0]["DTHOAI_NR"].ToString();
                lbDienThoaiSMS.Text = ds.Tables[0].Rows[0]["DTHOAI_SMS"].ToString();
                lbEmail.Text = ds.Tables[0].Rows[0]["EMAIL"].ToString();
                //lbDiemDo.Text = ds.Tables[0].Rows[0][10].ToString();
                //lbChuoiGia.Text = ds.Tables[0].Rows[0][11].ToString();
                //lbTram.Text = ds.Tables[0].Rows[0][12].ToString();
                //lbLo.Text = ds.Tables[0].Rows[0][14].ToString();
                //lbCot.Text = ds.Tables[0].Rows[0][16].ToString();
                gvInfo.DataSource = ds.Tables[0];
                gvInfo.DataBind();
                lbError.Text = "";

                ddNam.SelectedIndex = 0;
                Show_TienDien();

                pnThongTin.Visible = true;
                gvKhachHang.DataSource = null;
                gvKhachHang.DataBind();
            }
            catch (Exception ex)
            {
                lbTenKH.Text = "";
                lbDiaChi.Text = "";
                lbHopDong.Text = "";
                lbNgayKy.Text = "";
                lbGiaHan.Text = "";
                lbDienThoai.Text = "";
                lbDienThoaiSMS.Text = "";
                lbEmail.Text = "";
                gvInfo.DataSource = null;
                gvInfo.DataBind();
                lbError.Text = "Có lỗi trong quá trình đọc dữ liệu. " + ex.Message;
            }
        }
 protected void Tim_Kiem()
 {
     pnThongTin.Visible = false;
     try
     {
         CSKH_CMIS.Service_CSKHCMIS ob = new CSKH_CMIS.Service_CSKHCMIS();
         DataSet ds = ob.find_KHANG(lbPC.Text, ddDonViQL.SelectedValue, tbTenKH.Text, "", tbMaKH.Text);
         gvKhachHang.DataSource = ds;
         gvKhachHang.DataBind();
         if (gvKhachHang.Rows.Count == 0)
             lbError.Text = "Không tìm thấy khách hàng";
         else
             lbError.Text = string.Format("Kết quả tìm kiếm: {0} khách hàng.", ds.Tables[0].Rows.Count);
     }
     catch (Exception ex) { lbError.Text = "Có lỗi trong quá trình tìm kiếm. " + ex.Message; }
 }
 protected void gvLichSu_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "XEM")
     {
         int i = Convert.ToInt32(e.CommandArgument);
         CSKH_CMIS.Service_CSKHCMIS ob = new CSKH_CMIS.Service_CSKHCMIS();
         DataSet ds;
         if (gvLichSu.Rows[i].Cells[0].Text == "TD")
         {
             ds = ob.Get_Ctiethdon_TD(lbPC.Text, lbDonVi.Text, Int32.Parse(gvLichSu.Rows[i].Cells[8].Text));
             Label1.Visible = true;
             GridView1.DataSource = ds.Tables[0];
             GridView1.DataBind();
             Label2.Visible = true;
             GridView2.DataSource = ds.Tables[1];
             GridView2.DataBind();
             Label3.Visible = false;
             GridView3.DataSource = null;
             GridView3.DataBind();
         }
         else
         {
             ds = ob.Get_Ctiethdon_VC(lbPC.Text, lbDonVi.Text, Int32.Parse(gvLichSu.Rows[i].Cells[8].Text));
             Label1.Visible = false;
             GridView1.DataSource = null;
             GridView1.DataBind();
             Label2.Visible = false;
             GridView2.DataSource = null;
             GridView2.DataBind();
             Label3.Visible = true;
             GridView3.DataSource = ds.Tables[0];
             GridView3.DataBind();
         }
         pnChiTiet.CssClass = "pnUpdate";
         pnBack.CssClass = "pnBack";
     }
 }
 protected void Show_TienDien()
 {
     try
     {
         CSKH_CMIS.Service_CSKHCMIS ob = new CSKH_CMIS.Service_CSKHCMIS();
         DataSet ds = ob.Get_hdon_by_khang_nam(lbPC.Text, lbDonVi.Text, lbMaKH.Text, short.Parse(ddNam.SelectedValue));
         DataView dv = ds.Tables[0].DefaultView;
         dv.Sort = "THANG desc, KY desc";
         gvLichSu.DataSource = ds.Tables[0];
         gvLichSu.DataBind();
     }
     catch
     {
         gvLichSu.DataSource = null;
         gvLichSu.DataBind();
     }
 }