Exemplo n.º 1
0
        private string GetID(string username, string pass)
        {
            string id = "";

            try
            {
                con.MoKetNoi();
                // SqlCommand cmd = new SqlCommand("SELECT * FROM TaiKhoan WHERE TenDangNhap ='" + username + "' and MatKhau='" + pass + "'", connect);
                //  SqlDataAdapter da = new SqlDataAdapter(cmd);
                DataTable dt = con.LayDuLieuBang("SELECT * FROM TaiKhoan WHERE TenDangNhap ='" + username + "' and MatKhau='" + pass + "'");

                if (dt != null)
                {
                    foreach (DataRow dr in dt.Rows)
                    {
                        id = dr["id"].ToString();
                    }
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Lỗi xảy ra khi truy vấn dữ liệu hoặc kết nối với server thất bại !");
            }
            finally
            {
                con.DongKetNoi();
            }
            return(id);
        }
Exemplo n.º 2
0
        void LoadPhongTrong()
        {
            // connect = new SqlConnection(@"Data Source=DESKTOP-KMNS09Q\SQLEXPRESS;Initial Catalog=QuanLyKhachSan;Integrated Security=True");
            //connect.Open();
            // DataTable dt = connect.;
            // SqlDataAdapter data = new SqlDataAdapter("select MaPhong,TinhTrang from Phong1 where  MaPhong LIKE'" + tang.Text + "%' and TinhTrang ='trong' and LoaiPhong LIKE'" + loaiphong.Text + "' and Gia <= '" + gia.Text + "' ", connect);
            //data.Fill(dt);
            con.MoKetNoi();
            DataTable dt = con.LayDuLieuBang("select MaPhong, TinhTrang from Phong1 where MaPhong LIKE'" + tang.Text + "%' and TinhTrang = 'trong' and LoaiPhong LIKE'" + loaiphong.Text + "' and Gia <= '" + gia.Text + "' ");

            Phong.Items.Clear();
            Phong.View          = View.Details;
            Phong.FullRowSelect = true;
            Phong.GridLines     = true;
            Phong.CheckBoxes    = true;
            Phong.Columns.Add("ten phong");
            Phong.Columns.Add("tinhtrang");
            //   Phong.Columns.Add("Dat Phong");

            int i = 0;

            foreach (DataRow row in dt.Rows)
            {
                Phong.Items.Add(row["MaPhong"].ToString());
                Phong.Items[i].SubItems.Add(row["TinhTrang"].ToString());
                i++;
            }
        }
Exemplo n.º 3
0
        void LoadListView()
        {
            //lay du lieu phong
            //  connect = new SqlConnection(@"Data Source=DESKTOP-86M3SB6\SQLEXPRESS;Initial Catalog=QuanLyKhachSan;Integrated Security=True");
            //  connect.Open();
            //  DataTable dt = new DataTable();
            //  SqlDataAdapter data = new SqlDataAdapter("select MaPhong,TinhTrang from Phong1", connect);

            //  data.Fill(dt);
            con.MoKetNoi();
            DataTable dt = con.LayDuLieuBang("select MaPhong, TinhTrang,status from Phong1");

            //do du lieu vao list view
            DSP.Items.Clear();
            DSP.View = View.LargeIcon;
            DSP.Columns.Add("ten phong");
            DSP.Columns.Add("tinhtrang");
            DSP.Columns.Add("status");
            LoadIMG();
            DSP.LargeImageList = img;

            int i = 0;

            foreach (DataRow row in dt.Rows)
            {
                DSP.Items.Add(row["MaPhong"].ToString());
                DSP.Items[i].SubItems.Add(row["TinhTrang"].ToString());
                DSP.Items[i].SubItems.Add(row["status"].ToString());

                if (DSP.Items[i].SubItems[1].Text == "trong")
                {
                    DSP.Items[i].ImageIndex = 0;
                }
                else if (DSP.Items[i].SubItems[1].Text == "da dat")
                {
                    DSP.Items[i].ImageIndex = 1;
                }
                else
                {
                    DSP.Items[i].ImageIndex = 2;
                }
                i++;
            }
        }