public static DataTable laymasacht()
 {
     string sql;
     sql = "Select masach from Sach ";
     AccessData db = new AccessData();
     DataTable dt;
     dt = db.TaoBang(sql);
     return dt;
 }
 public static DataTable LayMaTheDocGia()
 {
     string sql;
     sql = "Select MaThe from The ";
     AccessData db = new AccessData();
     DataTable dt;
     dt = db.TaoBang(sql);
     return dt;
 }
示例#3
0
 public static DataTable LayTenTheLoai()
 {
     string sql;
     sql = "Select TenTheLoai from TheLoai ";
     AccessData db = new AccessData();
     DataTable dt;
     dt = db.TaoBang(sql);
     return dt;
 }
 public static DataTable LayMaSach()
 {
     string sql;
     sql = "Select MaSach from Sach where hientrang=N'Chưa thuê'";
     AccessData db = new AccessData();
     DataTable dt;
     dt = db.TaoBang(sql);
     return dt;
 }
示例#5
0
 public static DataTable LayTenNXB()
 {
     string sql;
     sql = "Select TenNhaXuatBan from NhaXuatBan ";
     AccessData db = new AccessData();
     DataTable dt;
     dt = db.TaoBang(sql);
     return dt;
 }
 public static DataTable LayMaTheMuon()
 {
     string sql;
     sql = "Select DISTINCT MaThe from PhieuMuon ";
     AccessData db = new AccessData();
     DataTable dt;
     dt = db.TaoBang(sql);
     return dt;
 }
示例#7
0
 public static DataTable LayTenSach()
 {
     string sql;
     sql = "Select TenSach from TuaSach ";
     AccessData db = new AccessData();
     DataTable dt;
     dt = db.TaoBang(sql);
     return dt;
 }
        private void cbxSoPhieu_SelectedIndexChanged(object sender, EventArgs e)
        {
            AccessData    ac  = new AccessData();
            string        str = "laymasach";
            SqlConnection con = new SqlConnection(ac.getconnect());

            con.Open();
            SqlCommand cmd = new SqlCommand(str, con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@maphieu", cbxSoPhieu.Text.ToString());
            SqlDataAdapter ad = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            ad.Fill(dt);
            cbxmtt.DataSource    = dt;
            cbxmtt.DisplayMember = "MaSach";
        }
 private void cbxMaTheMuon_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter)
     {
         AccessData    ac  = new AccessData();
         string        str = "laysophieu";
         SqlConnection con = new SqlConnection(ac.getconnect());
         con.Open();
         SqlCommand cmd = new SqlCommand(str, con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@mathe", cbxMaTheMuon.Text.ToString());
         SqlDataAdapter ad = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();
         ad.Fill(dt);
         cbxSoPhieu.DataSource    = dt;
         cbxSoPhieu.DisplayMember = "SoPhieu";
     }
 }
        private void btnMuon_Click(object sender, EventArgs e)
        {
            try
            {
                AccessData ac = new AccessData();

                string        str = "ThemPhieuMuon";
                SqlConnection con = new SqlConnection(ac.getconnect());
                con.Open();
                SqlCommand cmd = new SqlCommand(str, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@mathe", cbxMaTheMuon.Text);
                cmd.Parameters.AddWithValue("@ngaymuon", Convert.ToDateTime(dtNgayMuon.Text.ToString()));
                cmd.Parameters.AddWithValue("@ngaytra", Convert.ToDateTime(dtNgayHenTra.Text.ToString()));
                SqlParameter para = new SqlParameter("@kq", SqlDbType.Int);
                para.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(para);
                cmd.ExecuteNonQuery();
                string kq = para.Value.ToString();
                cmd.Dispose();
                con.Close();
                if (kq == "0")
                {
                    MessageBox.Show("Lỗi dữ liệu ngày mượn");
                }
                else
                if (kq == "1")
                {
                    MessageBox.Show("Lỗi dữ liệu ngày trả");
                }
                else
                if (kq == "3")
                {
                    MessageBox.Show("Thẻ đã mượn quá số lượng cho phép");
                }
                else
                {
                    MessageBox.Show("Thêm thành công");
                }
            }
            catch (Exception er)
            { MessageBox.Show(er.Message); }
        }
 private void cbxTenSachMuon_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         AccessData    ac  = new AccessData();
         string        str = "LaySach";
         SqlConnection con = new SqlConnection(ac.getconnect());
         con.Open();
         SqlCommand cmd = new SqlCommand(str, con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@tensach", cbxTenSachMuon.Text.ToString());
         SqlDataAdapter ad = new SqlDataAdapter(cmd);
         DataTable      dt = new DataTable();
         ad.Fill(dt);
         cbxMaSachMuon.DataSource    = dt;
         cbxMaSachMuon.DisplayMember = "MaSach";
     }
     catch (Exception er)
     { MessageBox.Show(er.Message); }
 }
示例#12
0
 private void cbxTenSachMuon_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         AccessData ac = new AccessData();
         string str = "LaySach";
         SqlConnection con = new SqlConnection(ac.getconnect());
         con.Open();
         SqlCommand cmd = new SqlCommand(str, con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@tensach", cbxTenSachMuon.Text.ToString());
         SqlDataAdapter ad = new SqlDataAdapter(cmd);
         DataTable dt = new DataTable();
         ad.Fill(dt);
         cbxMaSachMuon.DataSource = dt;
         cbxMaSachMuon.DisplayMember = "MaSach";
     }
     catch (Exception er)
     { MessageBox.Show(er.Message); }
 }
示例#13
0
 private void cbxSoPhieu_SelectedIndexChanged(object sender, EventArgs e)
 {
     AccessData ac = new AccessData();
     string str = "laymasach";
     SqlConnection con = new SqlConnection(ac.getconnect());
     con.Open();
     SqlCommand cmd = new SqlCommand(str, con);
     cmd.CommandType = CommandType.StoredProcedure;
     cmd.Parameters.AddWithValue("@maphieu", cbxSoPhieu.Text.ToString());
     SqlDataAdapter ad = new SqlDataAdapter(cmd);
     DataTable dt = new DataTable();
     ad.Fill(dt);
     cbxmtt.DataSource = dt;
     cbxmtt.DisplayMember = "MaSach";
 }
示例#14
0
 private void cbxMaTheMuon_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyData == Keys.Enter)
     {
         AccessData ac = new AccessData();
         string str = "laysophieu";
         SqlConnection con = new SqlConnection(ac.getconnect());
         con.Open();
         SqlCommand cmd = new SqlCommand(str, con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@mathe", cbxMaTheMuon.Text.ToString());
         SqlDataAdapter ad = new SqlDataAdapter(cmd);
         DataTable dt = new DataTable();
         ad.Fill(dt);
         cbxSoPhieu.DataSource = dt;
         cbxSoPhieu.DisplayMember = "SoPhieu";
     }
 }
示例#15
0
 private void bntChoMuon_Click(object sender, EventArgs e)
 {
     try
     {
         AccessData ac = new AccessData();
         string str = "Themchitietmuon";
         SqlConnection con = new SqlConnection(ac.getconnect());
         con.Open();
         SqlCommand cmd = new SqlCommand(str, con);
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@sophieu", cbxSP.Text);
         cmd.Parameters.AddWithValue("@masach", cbxMaSachMuon.Text);
         SqlParameter para = new SqlParameter("@kq", SqlDbType.Int);
         para.Direction = ParameterDirection.Output;
         cmd.Parameters.Add(para);
         cmd.ExecuteNonQuery();
         string kq = para.Value.ToString();
         if (kq == "0") MessageBox.Show("Dữ liệu đầu vào sai");
         else MessageBox.Show("Thêm thành công");
         cmd.Dispose();
         con.Close();
     }
     catch (Exception er)
     { MessageBox.Show(er.Message); }
 }
示例#16
0
 public static DataTable LayNgayHenTra()
 {
     string sql;
     sql = "Select NgayTra from PhieuMuon ";
     AccessData db = new AccessData();
     DataTable dt;
     dt = db.TaoBang(sql);
     return dt;
 }
示例#17
0
        private void btnMuon_Click(object sender, EventArgs e)
        {
            try
            {
                AccessData ac = new AccessData();

                string str = "ThemPhieuMuon";
                SqlConnection con = new SqlConnection(ac.getconnect());
                con.Open();
                SqlCommand cmd = new SqlCommand(str, con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@mathe", cbxMaTheMuon.Text);
                cmd.Parameters.AddWithValue("@ngaymuon", Convert.ToDateTime(dtNgayMuon.Text.ToString()));
                cmd.Parameters.AddWithValue("@ngaytra", Convert.ToDateTime(dtNgayHenTra.Text.ToString()));
                SqlParameter para = new SqlParameter("@kq", SqlDbType.Int);
                para.Direction = ParameterDirection.Output;
                cmd.Parameters.Add(para);
                cmd.ExecuteNonQuery();
                string kq = para.Value.ToString();
                cmd.Dispose();
                con.Close();
                if (kq == "0") MessageBox.Show("Lỗi dữ liệu ngày mượn");
                else
                    if (kq == "1") MessageBox.Show("Lỗi dữ liệu ngày trả");
                    else
                        if (kq == "3") MessageBox.Show("Thẻ đã mượn quá số lượng cho phép");
                        else
                            MessageBox.Show("Thêm thành công");
            }
            catch (Exception er)
            { MessageBox.Show(er.Message); }
        }