Example #1
0
        public static void Sua(CaChieuDTO cachieu)
        {
            // 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 = "EXEC SuaCaChieu @MACC,@TENCC,@BATDAU,@KETTHUC";
            command.Parameters.Add("@MACC", SqlDbType.VarChar, 10);
            command.Parameters.Add("@TENCC", SqlDbType.NVarChar, 100);
            command.Parameters.Add("@BATDAU", SqlDbType.DateTime);
            command.Parameters.Add("@KETTHUC", SqlDbType.DateTime);

            // gán giá trị
            command.Parameters["@MACC"].Value    = cachieu.MaCC;
            command.Parameters["@TENCC"].Value   = cachieu.TenCC;
            command.Parameters["@BATDAU"].Value  = cachieu.BatDau.ToLongTimeString();
            command.Parameters["@KETTHUC"].Value = cachieu.KetThuc.ToLongTimeString();

            command.ExecuteNonQuery();

            // đóng kết nối
            connection.Close();
        }
Example #2
0
        private void dtgDSCaChieu_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
        {
            int index = dtgDSCaChieu.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;
                CaChieuDTO nv = dtgDSCaChieu.SelectedItem as CaChieuDTO;
                txtMaCC.Text    = nv.MaCC;
                txtTenCC.Text   = nv.TenCC;
                txtBatdau.Text  = nv.BatDau_String;
                txtKetthuc.Text = nv.KetThuc_String;
            }
        }
        private void BtnLuu_Click(object sender, RoutedEventArgs e)
        {
            bool TrungMaCC = false;

SuaLai:
            string macc = null;

            if (txtMaCC.Text.Length != 0)
            {
                macc = txtMaCC.Text;
            }
            string tencc = null;

            if (txtTencc.Text.Length != 0)
            {
                tencc = txtTencc.Text;
            }

            string batdau = null;

            if (tpBatDau.Text.Length != 0)
            {
                batdau = emxinloi(tpBatDau.Text);
            }
            string ketthuc = null;

            if (tpKetThuc.Text.Length != 0)
            {
                ketthuc = emxinloi(tpKetThuc.Text);
            }

            CaChieuDTO cc = new CaChieuDTO(macc, tencc, DateTime.Parse(batdau.ToString()), DateTime.Parse(ketthuc.ToString()));

            if (macc == null)
            {
                if (TrungMaCC == false)
                {
                    MessageBox.Show("Mã ca chiếu không được để trống");
                }
                else
                {
                    MessageBox.Show("Mã ca chiếu bị trùng");
                }
                txtMaCC.Focus();
            }
            else if (tencc == null)
            {
                MessageBox.Show("Tên ca chiếu không được để trống");
                txtTencc.Focus();
            }
            else if (batdau == null)
            {
                MessageBox.Show("Thời gian bắt đầu không được để trống");
                txtBatdau.Focus();
            }

            else
            {
                try
                {
                    CaChieuBUS.Them(cc);
                }
                catch
                {
                    txtMaCC.Clear();
                    TrungMaCC = true;
                    goto SuaLai;
                }
                MessageBox.Show("Thêm thông tin ca chiếu  thành công", "Thông báo");
                this.Close();
            }
        }
Example #4
0
        private void BtnLuu_Sua_Click(object sender, RoutedEventArgs e)
        {
            bool TrungMaCC = false;

SuaLai:
            string macc = null;

            if (txtMaCC.Text.Length != 0)
            {
                macc = txtMaCC.Text;
            }
            string tencc = null;

            if (txtTenCC.Text.Length != 0)
            {
                tencc = txtTenCC.Text;
            }

            string batdau = null;

            if (txtBatdau.Text.Length != 0)
            {
                batdau = txtBatdau.Text;
            }
            string ketthuc = null;

            if (txtKetthuc.Text.Length != 0)
            {
                ketthuc = txtKetthuc.Text;
            }

            CaChieuDTO cc = new CaChieuDTO(macc, tencc, DateTime.Parse(batdau.ToString()), DateTime.Parse(ketthuc.ToString()));

            if (macc == null)
            {
                if (TrungMaCC == false)
                {
                    MessageBox.Show("Mã ca chiếu không được để trống");
                }
                else
                {
                    MessageBox.Show("Mã ca chiếu bị trùng");
                }
                txtMaCC.Focus();
            }
            else if (tencc == null)
            {
                MessageBox.Show("Tên ca chiếu không được để trống");
                txtTenCC.Focus();
            }
            else if (batdau == null)
            {
                MessageBox.Show("Thời gian bắt đầu không được để trống");
                txtBatdau.Focus();
            }
            else
            {
                try
                {
                    CaChieuBUS.Sua(cc);
                }
                catch
                {
                    txtMaCC.Clear();
                    TrungMaCC = true;
                    goto SuaLai;
                }
                MessageBox.Show("Sửa thông tin ca chiếu  thành công", "Thông báo");

                DataTable dataTable = new DataTable();
                dataTable = CaChieuBUS.LoadDSCaChieu();
                Load_Data(dataTable);

                KhongChoNhap();
                btnHuy_Sua.Visibility  = btnLuu_Sua.Visibility = Visibility.Hidden;
                btnSua.Visibility      = Visibility.Visible;
                btnThem.IsEnabled      = btnXoa.IsEnabled = true;
                dtgDSCaChieu.IsEnabled = true;
                Selected = false;
            }
        }
Example #5
0
 public static void Sua(CaChieuDTO cc)
 {
     CaChieuDAO.Sua(cc);
 }
Example #6
0
 public static void Them(CaChieuDTO cc)
 {
     CaChieuDAO.Them(cc);
 }