Ejemplo n.º 1
0
        public static void Sua(LoaiVeDTO loaive)
        {
            // mở kết nối
            SqlConnection connection = SQLConnectionData.HamKetNoi();

            connection.Open();

            // tạo câu lệnh Thêm
            SqlCommand command = connection.CreateCommand();

            command.CommandType = CommandType.Text;
            //command.CommandText = "INSERT INTO NHANVIEN VALUES(@MANV,@HOTEN,@CHUCVU,@SDT,@GIOITINH,@NGAYSINH,@DIACHI,@LUONG,@NGAYVL)";
            command.CommandText = "EXEC SuaLoaiVe @MALV,@TENLV,@LOAICHONGOI,@GIA";

            command.Parameters.Add("@MALV", SqlDbType.VarChar, 10);
            command.Parameters.Add("@TENLV", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@LOAICHONGOI", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@GIA", SqlDbType.Money);

            // gán giá trị
            command.Parameters["@MALV"].Value        = loaive.MaLV;
            command.Parameters["@TENLV"].Value       = loaive.TenLV;
            command.Parameters["@LOAICHONGOI"].Value = loaive.LoaiChoNgoi;
            command.Parameters["@GIA"].Value         = loaive.Gia;


            command.ExecuteNonQuery();

            // đóng kết nối
            connection.Close();
        }
Ejemplo n.º 2
0
        private void btnLuu_Click(object sender, RoutedEventArgs e)
        {
            string malv = "LV" + (SoLuongMaLV + 1).ToString();

Nhaplai:
            string tenlv = null;

            if (txtTenLV.Text.Length != 0)
            {
                tenlv = txtTenLV.Text;
            }

            string loaichongoi = null;

            if (txtLoaiChoNgoi.Text.Length != 0)

            {
                loaichongoi = txtLoaiChoNgoi.Text;
            }

            string gia = null;

            if (txtGia.Text.Length != 0)
            {
                gia = txtGia.Text;
            }

            LoaiVeDTO loaive = new LoaiVeDTO(malv, tenlv, loaichongoi, gia);

            // báo lỗi nếu chưa nhập theo thứ tự trừ trên xuống , trái sang phải

            if (tenlv == null)
            {
                MessageBox.Show("Chưa nhập tên loại vé");
                txtTenLV.Focus();
            }
            else if (loaichongoi == null)
            {
                MessageBox.Show("Chưa nhập loại chỗ ngồi");
                txtLoaiChoNgoi.Focus();
            }
            else if (gia == null)
            {
                MessageBox.Show("Chưa nhập giá");
                txtGia.Focus();
            }
            else
            {
                try
                {
                    LoaiVeBUS.Them(loaive);
                }
                catch
                {
                    goto Nhaplai;
                }
                MessageBox.Show("Thêm loại vé mới thành công", "Thông báo");
                this.Close();
            }
        }
Ejemplo n.º 3
0
        public static void Them(LoaiVeDTO loaive)
        {
            // mở kết nối
            SqlConnection connection = SQLConnectionData.HamKetNoi();

            connection.Open();

            // tạo câu lệnh Thêm
            SqlCommand command = connection.CreateCommand();

            command.CommandType = CommandType.Text;
            //command.CommandText = "INSERT INTO PHIM VALUES(@MALV,@TENLV,@LOAICHONGOI,@GIA,@MALP,@NOIDUNG,@NAMSX,@NUOCSX,@THOILUONG)";
            command.CommandText = "EXEC ThemLoaiVe @MALV,@TENLV,@LOAICHONGOI,@GIA";

            command.Parameters.Add("@MALV", SqlDbType.VarChar, 10);
            command.Parameters.Add("@TENLV", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@LOAICHONGOI", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@GIA", SqlDbType.Money);

            // gán giá trị
            command.Parameters["@MALV"].Value        = loaive.MaLV;
            command.Parameters["@TENLV"].Value       = loaive.TenLV;
            command.Parameters["@LOAICHONGOI"].Value = loaive.LoaiChoNgoi;
            command.Parameters["@GIA"].Value         = loaive.Gia;

            command.ExecuteNonQuery();

            // đóng kết nối
            connection.Close();
        }
Ejemplo n.º 4
0
        private void dtgDSLoaiVe_MouseUp(object sender, MouseButtonEventArgs e)
        {
            int index = dtgDSLoaiVe.SelectedIndex;

            if (index >= 0) // tránh lỗi click vẫn trong datagrid nhưng mà click chỗ k có dòng nào
            {
                Selected = true;
                LoaiVeDTO nv = dtgDSLoaiVe.SelectedItem as LoaiVeDTO;
                txtMaLV.Text        = nv.MaLV;
                txtTenLV.Text       = nv.TenLV;
                txtLoaiChoNgoi.Text = nv.LoaiChoNgoi;
                txtGia.Text         = nv.Gia;
            }
        }
Ejemplo n.º 5
0
        private void btnLuu_Sua_Click(object sender, RoutedEventArgs e)

        {
            bool TrungMaLV = false;

SuaLai:
            string malv = null;

            if (txtMaLV.Text.Length != 0)
            {
                malv = txtMaLV.Text;
            }
            string tenlv = null;

            if (txtTenLV.Text.Length != 0)
            {
                tenlv = txtTenLV.Text;
            }
            string loaichongoi = null;

            if (txtLoaiChoNgoi.Text.Length != 0)
            {
                loaichongoi = txtLoaiChoNgoi.Text;
            }
            string gia = null;

            if (txtGia.Text.Length != 0)
            {
                gia = txtGia.Text;
                gia = ReMoney(gia);
            }

            LoaiVeDTO nv = new LoaiVeDTO(malv, tenlv, loaichongoi, gia);


            if (malv == null)
            {
                if (TrungMaLV == false)
                {
                    MessageBox.Show("Mã loại vé không được để trống");
                }
                else
                {
                    MessageBox.Show("Mã loại vé bị trùng");
                }
                txtMaLV.Focus();
            }
            else if (tenlv == null)
            {
                MessageBox.Show("Tên loại vé không được để trống");
                txtTenLV.Focus();
            }
            else if (loaichongoi == null)
            {
                MessageBox.Show("Loại chỗ ngồi không được để trống");
                txtLoaiChoNgoi.Focus();
            }
            else if (gia == null)
            {
                MessageBox.Show("Giá không được để trống");
                txtGia.Focus();
            }
            else
            {
                try
                {
                    LoaiVeBUS.Sua(nv);
                }
                catch
                {
                    txtMaLV.Clear();
                    TrungMaLV = true;
                    goto SuaLai;
                }
                MessageBox.Show("Sửa thông tin loại vé thành công", "Thông báo");

                DataTable dataTable = new DataTable();
                dataTable = LoaiVeBUS.LoadDSLoaiVe();
                Load_Data(dataTable);

                KhongChoNhap();
                btnHuy_Sua.Visibility = btnLuu_Sua.Visibility = Visibility.Hidden;
                btnSua.Visibility     = Visibility.Visible;
                btnThem.IsEnabled     = btnXoa.IsEnabled = true;
                dtgDSLoaiVe.IsEnabled = true;
                Selected = false;
            }
        }
Ejemplo n.º 6
0
 public static void Sua(LoaiVeDTO p)
 {
     LoaiVeDAO.Sua(p);
 }
Ejemplo n.º 7
0
 public static void Them(LoaiVeDTO p)
 {
     LoaiVeDAO.Them(p);
 }