private void btupdate_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    using (SqlCommand cmd = new SqlCommand("sp_SuaSuatChieu", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@idsuatchieu", SqlDbType.Int);
                        cmd.Parameters.Add("@idphongmoi", SqlDbType.Int);
                        cmd.Parameters.Add("@ngaymoi", SqlDbType.Date);
                        cmd.Parameters.Add("@thoigianbdmoi", SqlDbType.Date);
                        cmd.Parameters.Add("@iddinhdangmoi", SqlDbType.Char);

                        cmd.Parameters["@idsuatchieu"].Value   = this.idsuat;
                        cmd.Parameters["@idphongmoi"].Value    = cbphong.Text;
                        cmd.Parameters["@ngaymoi"].Value       = dtpk_dateForm.Value.Date;
                        cmd.Parameters["@thoigianbdmoi"].Value = cbThoiGianBatDau.Text;
                        cmd.Parameters["@iddinhdangmoi"].Value = cbdinhdang.Text;
                        conn.Open();
                        cmd.ExecuteScalar();
                        conn.Close();
                        MessageBox.Show("Sua thanh cong");
                    }
            }catch (Exception err)
            {
            }
        }
        private void btinsert_Click(object sender, EventArgs e)
        {
            try
            {
                using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    using (SqlCommand cmd = new SqlCommand("sp_ThemSuatChieu", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        //MessageBox.Show(cb_film.SelectedValue.ToString(), "id film");
                        cmd.Parameters.Add("@idphong", SqlDbType.Int);
                        cmd.Parameters.Add("@ngay", SqlDbType.Date);
                        cmd.Parameters.Add("@thoigianbd", SqlDbType.DateTime);
                        cmd.Parameters.Add("@idphim", SqlDbType.Int);
                        cmd.Parameters.Add("@iddinhdang", SqlDbType.Char);

                        cmd.Parameters["@idphong"].Value    = int.Parse(cbphong.SelectedValue.ToString());
                        cmd.Parameters["@ngay"].Value       = dtpk_dateInsertLichChieu.Value.ToString();
                        cmd.Parameters["@thoigianbd"].Value = cbThoiGianBatDau.Text;
                        cmd.Parameters["@idphim"].Value     = int.Parse(cbphim.SelectedValue.ToString());
                        cmd.Parameters["@iddinhdang"].Value = cbdinhdang.Text;
                        conn.Open();
                        cmd.ExecuteScalar();
                        SqlDataAdapter da = new SqlDataAdapter(cmd);


                        conn.Close();
                        MessageBox.Show("Them thanh cong");
                    }
                this.Close();
            }catch (Exception err)
            {
                MessageBox.Show("Khong the them");
            }
        }
示例#3
0
        private void btn_book_Click(object sender, EventArgs e)
        {
            int    index   = dgv_seat.CurrentCell.RowIndex;
            String veTrong = dgv_seat.Rows[index].Cells[5].Value.ToString();

            if (veTrong.Equals("Trống"))
            {
                using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    using (SqlCommand cmd = new SqlCommand("sp_DatCho", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@ve", SqlDbType.Int);
                        cmd.Parameters.Add("@thanhvien", SqlDbType.Char);
                        cmd.Parameters["@ve"].Value        = int.Parse(dgv_seat.Rows[index].Cells[1].Value.ToString());
                        cmd.Parameters["@thanhvien"].Value = tb_identity.Text;
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
            }
            else
            {
                MessageBox.Show("Khong the dat duoc");
            }
        }
示例#4
0
        void refresh_form_GetTicket(int idve, int nhanvienbanhang, string uudai, string loaive)
        {
            using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                using (SqlCommand cmd = new SqlCommand("sp_LayVe", conn))
                {
                    //Cấu trúc: procedure sp_LayVe @ve int, @nhanvienbanhang int, @uudai nvarchar(20), @loaive nvarchar(5)
                    cmd.CommandType = CommandType.StoredProcedure;
                    //Thêm tham số
                    cmd.Parameters.Add("@ve", SqlDbType.Int);
                    cmd.Parameters.Add("@nhanvienbanhang", SqlDbType.Int);
                    cmd.Parameters.Add("@uudai", SqlDbType.NVarChar, 20);
                    cmd.Parameters.Add("@loaive", SqlDbType.NVarChar, 5);

                    cmd.Parameters["@ve"].Value = idve;
                    cmd.Parameters["@nhanvienbanhang"].Value = nhanvienbanhang;
                    if (uudai == "Không")
                    {
                        cmd.Parameters["@uudai"].Value = DBNull.Value;
                    }
                    else
                    {
                        cmd.Parameters["@uudai"].Value = uudai;
                    }
                    cmd.Parameters["@loaive"].Value = loaive;

                    conn.Open();
                    cmd.ExecuteNonQuery();
                    loadBookedTicket(conn);
                    conn.Close();
                }
        }
示例#5
0
        private void btn_statistic_Click(object sender, EventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                using (SqlCommand cmd = new SqlCommand("sp_ThongKe", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    //MessageBox.Show(cb_film.SelectedValue.ToString(), "id film");
                    cmd.Parameters.Add("@rap", SqlDbType.Int);
                    cmd.Parameters.Add("@phim", SqlDbType.Int);
                    cmd.Parameters.Add("@ngayBD", SqlDbType.Date);
                    cmd.Parameters.Add("@ngayKT", SqlDbType.Date);

                    cmd.Parameters["@rap"].Value = getCinemaID();
                    if (cbThongke_TatCaPhim.Checked)
                    {
                        cmd.Parameters["@phim"].Value = DBNull.Value;
                    }
                    else
                    {
                        cmd.Parameters["@phim"].Value = int.Parse(cb_film.SelectedValue.ToString());
                    }
                    cmd.Parameters["@ngayBD"].Value = dtpk_dateFrom.Value.Date;
                    cmd.Parameters["@ngayKT"].Value = dtpk_dateTo.Value.Date;
                    conn.Open();
                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    dgv_statistic.DataSource = dt;
                    conn.Close();
                }
        }
示例#6
0
        private void btn_huy_Click(object sender, EventArgs e)
        {
            try
            {
                if (dgv_vedat.SelectedCells.Count > 0)
                {
                    int idve = Convert.ToInt32(dgv_vedat[0, dgv_vedat.CurrentRow.Index].Value.ToString());

                    using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    {
                        conn.Open();
                        SqlCommand cmd = new SqlCommand("sp_HuyDatCho", conn);

                        // set the command object so it knows to execute a stored procedure
                        cmd.CommandType = CommandType.StoredProcedure;

                        // add parameter to command, which will be passed to the stored procedure
                        cmd.Parameters.Add(new SqlParameter("@idve", idve));

                        cmd.ExecuteNonQuery();

                        loadBookedTicket(conn);
                        conn.Close();
                    }
                }
            }
            catch
            {
            }
        }
示例#7
0
        private void btn_book_Click(object sender, EventArgs e)
        {
            int    index   = dgv_seat.CurrentCell.RowIndex;
            String veTrong = dgv_seat.Rows[index].Cells[5].Value.ToString();

            if (veTrong.Equals("Trống"))
            {
                if (tb_identity.Text == null || string.IsNullOrWhiteSpace(tb_identity.Text))
                {
                    MessageBox.Show("Hãy nhập cmnd");
                    return;
                }
                using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    using (SqlCommand cmd = new SqlCommand("sp_DatCho", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@ve", SqlDbType.Int);
                        cmd.Parameters.Add("@thanhvien", SqlDbType.Char);
                        cmd.Parameters["@ve"].Value        = int.Parse(dgv_seat.Rows[index].Cells[1].Value.ToString());
                        cmd.Parameters["@thanhvien"].Value = tb_identity.Text;
                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                        MessageBox.Show("Đặt vé thành công");
                    }
            }
            else
            {
                MessageBox.Show("Không thể đặt được");
            }
        }
示例#8
0
 private void btn_deleteShowtime_Click(object sender, EventArgs e)
 {
     if (index != -1)
     {
         DataGridViewRow selectedRow = dgv_showtime.Rows[index];
         string          idsuat      = selectedRow.Cells[0].Value.ToString();
         using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
             using (SqlCommand cmd = new SqlCommand("sp_XoaSuatChieu", conn))
             {
                 cmd.CommandType = CommandType.StoredProcedure;
                 cmd.Parameters.Add("@idsuatchieu", SqlDbType.Int);
                 cmd.Parameters["@idsuatchieu"].Value = idsuat;
                 conn.Open();
                 cmd.ExecuteScalar();
                 using (SqlConnection con = new SqlConnection(SQLConnection.connectionString()))
                 {
                     loadTabShowtimes(con);
                 }
                 MessageBox.Show("Xoa thanh cong");
             }
     }
     else
     {
         MessageBox.Show("Vui long chon suat");
     }
 }
示例#9
0
 private void buttonReFreshPhim_Click(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
     {
         conn.Open();
         loadTabFilm(conn);
         conn.Close();
     }
 }
示例#10
0
 private void fTicketClerk_Load(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
     {
         conn.Open();
         loadTabShowtimes(conn);
         conn.Close();
     }
 }
示例#11
0
 private void buttonRefreshLichChieu_Click(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
     {
         conn.Open();
         loadTabShowtimes(conn);
         conn.Close();
     }
 }
示例#12
0
 private void fManager_Load(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
     {
         conn.Open();
         loadTabFilm(conn);
         loadTabShowtimes(conn);
         loadTabStatistic(conn);
         conn.Close();
     }
 }
示例#13
0
        private void gbxIconType_CheckedChanged(object sender, EventArgs e)
        {
            if (index != -1)
            {
                float giaVe;
                using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    using (SqlCommand cmd = new SqlCommand("sp_laygiave", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@idghe", SqlDbType.Int);
                        cmd.Parameters.Add("@loaive", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@uudai", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@giave", SqlDbType.Float);
                        cmd.Parameters["@idghe"].Value = int.Parse(dgv_seat.Rows[index].Cells[2].Value.ToString());
                        if (rb_monday.Checked)
                        {
                            cmd.Parameters["@uudai"].Value = "Monday";
                        }
                        else if (rb_giasoc.Checked)
                        {
                            cmd.Parameters["@uudai"].Value = "GiaSoc";
                        }
                        else if (rb_birthday.Checked)
                        {
                            cmd.Parameters["@uudai"].Value = "SinhNhat";
                        }
                        else
                        {
                            cmd.Parameters["@uudai"].Value = DBNull.Value;
                        }

                        if (rb_adult.Checked)
                        {
                            cmd.Parameters["@loaive"].Value = "NL";
                        }
                        else if (rb_child.Checked)
                        {
                            cmd.Parameters["@loaive"].Value = "TE";
                        }
                        else if (rb_student.Checked)
                        {
                            cmd.Parameters["@loaive"].Value = "HSSV";
                        }
                        cmd.Parameters["@giave"].Direction = ParameterDirection.Output;
                        conn.Open();
                        cmd.ExecuteScalar();
                        giaVe = float.Parse(cmd.Parameters["@giave"].Value.ToString());
                        conn.Close();
                    }
                tb_price.Text = ((int)((int)(giaVe / 1000) * 1000)).ToString();
            }
        }
        private void insertLichChieu_Load(object sender, EventArgs e)
        {
            using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
            {
                loadPhim(conn);
                loadPhong(conn);
            }

            dtpk_dateInsertLichChieu.Value = DateTime.Today;
            tb_dateFrom.Text = Date(dtpk_dateInsertLichChieu.Value);

            this.cbdinhdang.Items.AddRange(new object[] { "2D", "3D" });
        }
示例#15
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(tbTuaPhim.Text) || String.IsNullOrWhiteSpace(tbTuaPhim.Text) ||
                String.IsNullOrEmpty(tbDaoDien.Text) || String.IsNullOrWhiteSpace(tbDaoDien.Text) ||
                String.IsNullOrEmpty(cbTheLoai.Text) || String.IsNullOrWhiteSpace(cbTheLoai.Text) ||
                String.IsNullOrEmpty(cbTheLoai.Text) || String.IsNullOrWhiteSpace(cbTheLoai.Text) ||
                String.IsNullOrEmpty(tbNuocSanXuat.Text) || String.IsNullOrWhiteSpace(tbNuocSanXuat.Text) ||
                String.IsNullOrEmpty(tbNgayCongChieu.Text) || String.IsNullOrWhiteSpace(tbNgayCongChieu.Text) ||
                String.IsNullOrEmpty(cbTinhTrang.Text) || String.IsNullOrWhiteSpace(cbTinhTrang.Text)
                )
            {
                MessageBox.Show("Vui long nhap day du thong tin");
            }
            else
            {
                using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    using (SqlCommand cmd = new SqlCommand("SP_CapNhatPhim", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        //MessageBox.Show(cb_film.SelectedValue.ToString(), "id film");
                        cmd.Parameters.Add("@idphim", SqlDbType.Int);
                        cmd.Parameters.Add("@tuaphim", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@theloai", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@daodien", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@ngaycongchieu", SqlDbType.Date);
                        cmd.Parameters.Add("@thoiluong", SqlDbType.Int);
                        cmd.Parameters.Add("@nuocsx", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@namsx", SqlDbType.Int);
                        cmd.Parameters.Add("@tinhtrang", SqlDbType.NVarChar);

                        cmd.Parameters["@idphim"].Value        = idPhim;
                        cmd.Parameters["@tuaphim"].Value       = tbTuaPhim.Text;
                        cmd.Parameters["@theloai"].Value       = cbTheLoai.Text;
                        cmd.Parameters["@daodien"].Value       = tbDaoDien.Text;
                        cmd.Parameters["@ngaycongchieu"].Value = dtpkNgayCongChieu.Value.Date;
                        cmd.Parameters["@thoiluong"].Value     = numericUpDownThoiLuong.Value;
                        cmd.Parameters["@nuocsx"].Value        = tbNuocSanXuat.Text;
                        cmd.Parameters["@namsx"].Value         = numericUpDownNamSanXuat.Value;
                        cmd.Parameters["@tinhtrang"].Value     = cbTinhTrang.Text;

                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                    }
                MessageBox.Show("Cập nhật thành công");
                this.Close();
            }
        }
示例#16
0
 private void loadSeat()
 {
     using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
         using (SqlCommand cmd = new SqlCommand("sp_XemChoNgoi", conn))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@idsuatchieu", SqlDbType.Int);
             cmd.Parameters["@idsuatchieu"].Value = int.Parse(showtimeID);
             conn.Open();
             SqlDataAdapter da = new SqlDataAdapter(cmd);
             DataTable      dt = new DataTable();
             da.Fill(dt);
             dgv_seat.DataSource = dt;
             conn.Close();
         }
 }
        private void UpdateLichChieu_Load(object sender, EventArgs e)
        {
            tbidsuatchieu.Text    = idsuat;
            cbphong.Text          = idphong;
            tbphim.Text           = idphim;
            dtpk_dateForm.Text    = ngay;
            tb_dateForm.Text      = ngay;
            cbThoiGianBatDau.Text = time;
            cbdinhdang.Text       = iddinhdang;
            this.cbdinhdang.Items.AddRange(new object[] { "2D", "3D" });

            using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
            {
                loadPhong(conn);
            }
        }
示例#18
0
        private void cb_loaive_Load()
        {
            using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                using (SqlCommand cmd = new SqlCommand("SP_LietKeLoaiVe", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    conn.Open();
                    cmd.ExecuteScalar();

                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    cb_loaive.DataSource    = dt;
                    cb_loaive.ValueMember   = "idloaive";
                    cb_loaive.DisplayMember = "idloaive";
                    cb_loaive.DropDownStyle = ComboBoxStyle.DropDownList;
                }
        }
示例#19
0
        private int getCinemaID()
        {
            int cinemaID = 0;

            using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                using (SqlCommand cmd = new SqlCommand("sp_LamViecORap", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@nhanvien", SqlDbType.Int);
                    cmd.Parameters.Add("@rap", SqlDbType.Int);
                    cmd.Parameters["@nhanvien"].Value = employeeID;
                    cmd.Parameters["@rap"].Direction  = ParameterDirection.Output;
                    conn.Open();
                    cmd.ExecuteScalar();
                    cinemaID = (int)cmd.Parameters["@rap"].Value;
                    conn.Close();
                }
            return(cinemaID);
        }
示例#20
0
 private void btn_add_Click(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
         using (SqlCommand cmd = new SqlCommand("sp_ThemThanhVien", conn))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@cmnd", SqlDbType.Char);
             cmd.Parameters.Add("@sdt", SqlDbType.Char);
             cmd.Parameters.Add("@tenthanhvien", SqlDbType.NVarChar);
             cmd.Parameters.Add("@ngaysinh", SqlDbType.Date);
             cmd.Parameters["@cmnd"].Value         = tb_identityCard.Text;
             cmd.Parameters["@sdt"].Value          = tb_phoneNumber.Text;
             cmd.Parameters["@tenthanhvien"].Value = tb_name.Text;
             cmd.Parameters["@ngaysinh"].Value     = dtpk_dob.Value.Date;
             conn.Open();
             cmd.ExecuteNonQuery();
             conn.Close();
         }
     MessageBox.Show("Thêm thành viên thành công!");
 }
示例#21
0
 void Refresh_form_fAddMember(string cmnd, string sdt, string tenthanhvien, DateTime ngaysinh)
 {
     using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
         using (SqlCommand cmd = new SqlCommand("sp_ThemThanhVien", conn))
         {
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add("@cmnd", SqlDbType.Char);
             cmd.Parameters.Add("@sdt", SqlDbType.Char);
             cmd.Parameters.Add("@tenthanhvien", SqlDbType.NVarChar);
             cmd.Parameters.Add("@ngaysinh", SqlDbType.Date);
             cmd.Parameters["@cmnd"].Value         = cmnd;
             cmd.Parameters["@sdt"].Value          = sdt;
             cmd.Parameters["@tenthanhvien"].Value = tenthanhvien;
             cmd.Parameters["@ngaysinh"].Value     = ngaysinh.Date;
             conn.Open();
             cmd.ExecuteNonQuery();
             loadMembers(conn);
             conn.Close();
         }
 }
示例#22
0
        private void cb_uudai_Load()
        {
            using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                using (SqlCommand cmd = new SqlCommand("SP_LietKeUuDai", conn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    conn.Open();
                    cmd.ExecuteScalar();

                    SqlDataAdapter da = new SqlDataAdapter(cmd);
                    DataTable      dt = new DataTable();
                    da.Fill(dt);
                    DataRow row = dt.NewRow();
                    row["iduudai"] = "Không";
                    dt.Rows.InsertAt(row, 0);
                    cb_uudai.DataSource    = dt;
                    cb_uudai.ValueMember   = "iduudai";
                    cb_uudai.DisplayMember = "iduudai";
                    cb_uudai.DropDownStyle = ComboBoxStyle.DropDownList;
                }
        }
示例#23
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(tb_username.Text))
            {
                MessageBox.Show("Hãy nhập tên đăng nhập!");
            }
            else if (string.IsNullOrEmpty(tb_password.Text))
            {
                MessageBox.Show("Hãy nhập mật khẩu!");
            }
            else
            {
                string position = "";
                if (rb_manager.Checked)
                {
                    position = "QL";
                }
                else if (rb_seller.Checked)
                {
                    position = "NV";
                }

                using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    using (SqlCommand cmd = new SqlCommand("sp_DangNhap", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;

                        cmd.Parameters.Add("@cmnd", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@matKhau", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@idnhanvien", SqlDbType.Int);
                        cmd.Parameters["@cmnd"].Value           = tb_username.Text;
                        cmd.Parameters["@matKhau"].Value        = tb_password.Text;
                        cmd.Parameters["@idnhanvien"].Direction = ParameterDirection.Output;

                        conn.Open();
                        cmd.ExecuteScalar();
                        //cmd.ExecuteNonQuery();

                        employeeID = (int)cmd.Parameters["@idnhanvien"].Value;
                        if (employeeID > 0)
                        {
                            if (position == "QL")
                            {
                                fManager form = new fManager();
                                this.Hide();
                                form.ShowDialog();
                                this.Show();
                            }
                            else
                            {
                                fTicketClerk form = new fTicketClerk();
                                this.Hide();
                                form.ShowDialog();
                                this.Show();
                            }
                        }
                        else
                        {
                            MessageBox.Show("Đăng nhập thất bại!");
                        }

                        conn.Close();
                    }
            }
        }
示例#24
0
        private void btn_buy_Click(object sender, EventArgs e)
        {
            int    index   = dgv_seat.CurrentCell.RowIndex;
            String veTrong = dgv_seat.Rows[index].Cells[5].Value.ToString();

            if (veTrong.Equals("Trống"))
            {
                using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
                    using (SqlCommand cmd = new SqlCommand("sp_BanVe", conn))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@ve", SqlDbType.Int);
                        cmd.Parameters.Add("@thanhvien", SqlDbType.Char);
                        cmd.Parameters.Add("@nhanvienbanhang", SqlDbType.Int);
                        cmd.Parameters.Add("@uudai", SqlDbType.NVarChar);
                        cmd.Parameters.Add("@loaive", SqlDbType.NVarChar);

                        cmd.Parameters["@ve"].Value = int.Parse(dgv_seat.Rows[index].Cells[1].Value.ToString());
                        if (tb_identity == null || string.IsNullOrWhiteSpace(tb_identity.Text))
                        {
                            cmd.Parameters["@thanhvien"].Value = DBNull.Value;
                        }
                        else
                        {
                            cmd.Parameters["@thanhvien"].Value = tb_identity.Text;
                        }
                        cmd.Parameters["@nhanvienbanhang"].Value = fLogin.employeeID;

                        if (rb_monday.Checked)
                        {
                            cmd.Parameters["@uudai"].Value = "Monday";
                        }
                        else if (rb_giasoc.Checked)
                        {
                            cmd.Parameters["@uudai"].Value = "GiaSoc";
                        }
                        else if (rb_birthday.Checked)
                        {
                            cmd.Parameters["@uudai"].Value = "SinhNhat";
                        }
                        else
                        {
                            cmd.Parameters["@uudai"].Value = DBNull.Value;
                        }

                        if (rb_adult.Checked)
                        {
                            cmd.Parameters["@loaive"].Value = "NL";
                        }
                        else if (rb_child.Checked)
                        {
                            cmd.Parameters["@loaive"].Value = "TE";
                        }
                        else if (rb_student.Checked)
                        {
                            cmd.Parameters["@loaive"].Value = "HSSV";
                        }

                        conn.Open();
                        cmd.ExecuteNonQuery();
                        conn.Close();
                        MessageBox.Show("Mua vé thành công");
                    }
            }
            else
            {
                MessageBox.Show("Không thể mua được");
            }
        }
示例#25
0
 private void btn_statistic_Click(object sender, EventArgs e)
 {
     using (SqlConnection conn = new SqlConnection(SQLConnection.connectionString()))
         thongke(conn);
 }