Ejemplo n.º 1
0
        private void txtdausach_Click(object sender, EventArgs e)
        {
            FormDauSach f = new FormDauSach();

            f.Show();
            Hide();
        }
Ejemplo n.º 2
0
        private void btnThoat_Click(object sender, EventArgs e)
        {
            FormDauSach f = new FormDauSach();

            Hide();
            f.ShowDialog();
        }
Ejemplo n.º 3
0
        private void button1_Click(object sender, EventArgs e)
        {
            connect();
            if (txtGia.Text == "" || txtMaHienThi.Text == "" || txtNamXuatBan.Text == "" || txtSoLuongLyThuyet.Text == "" || txtSoTrang.Text == "" || txtTen.Text == "")
            {
                MessageBox.Show("Bạn chưa nhập đủ dữ liệu !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                try
                {
                    SqlCommand command = new SqlCommand("sp_THEMDAUSACH", conn);
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.Add(new SqlParameter("@mahienthi", txtMaHienThi.Text));
                    command.Parameters.Add(new SqlParameter("@ten", txtTen.Text));
                    command.Parameters.Add(new SqlParameter("@soluong", int.Parse(txtSoLuongLyThuyet.Text)));
                    command.Parameters.Add(new SqlParameter("@sotrang", int.Parse(txtSoTrang.Text)));
                    command.Parameters.Add(new SqlParameter("@gia", decimal.Parse(txtGia.Text)));
                    command.Parameters.Add(new SqlParameter("@namxb", int.Parse(txtNamXuatBan.Text)));
                    command.Parameters.Add(new SqlParameter("@maloaisach", cbbMaLoaiSach.SelectedValue));
                    command.Parameters.Add(new SqlParameter("@matg", cbbMaTacGia.SelectedValue));
                    command.Parameters.Add(new SqlParameter("@manxb", cbbMaNXB.SelectedValue));
                    command.Parameters.Add(new SqlParameter("@mavt", cbbMaViTri.SelectedValue));

                    command.ExecuteNonQuery();
                    MessageBox.Show("Thêm thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    if (MessageBox.Show("Thêm nữa không?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        txtMaHienThi.Clear();
                        txtGia.Clear();
                        txtNamXuatBan.Clear();
                        txtSoLuongLyThuyet.Clear();
                        txtSoTrang.Clear();
                        txtTen.Clear();
                        return;
                    }
                    FormDauSach f = new FormDauSach();
                    f.Show();
                    Hide();
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Thêm không thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            disconect();
        }
Ejemplo n.º 4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            connect();
            if (txtSoLuongBoSung.Text.Trim() == "")
            {
                MessageBox.Show("Chưa nhập gì");
                return;
            }
            try
            {
                if (int.Parse(txtSoLuongBoSung.Text) > 0)
                {
                    SqlCommand command = new SqlCommand("sp_BOSUNGDAUSACH", conn);
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.Add(new SqlParameter("@ma", int.Parse(txtMa.Text)));
                    command.Parameters.Add(new SqlParameter("@soluong", int.Parse(txtSoLuongBoSung.Text)));
                    command.ExecuteNonQuery();
                    MessageBox.Show("Thêm thành công !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    FormDauSach f = new FormDauSach();
                    f.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Số lượng không hợp lệ. Mời nhập lại !", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("đéo đúng kiểu dữ liệu", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            disconect();
        }