private void btnLuu_Click(object sender, EventArgs e)
        {
            TSDTO tsDTO = new TSDTO();

            //2. Kiểm tra dữ liệu
            if (checkNullData())
            {
                tsDTO.SoLuongSanBayTrungGianToiDa = int.Parse(txbSoSanBayTrungGianToiDa.Text);
                tsDTO.ThoiGianDungToiDa           = int.Parse(txbThoiGianDungToiDa.Text);
                tsDTO.ThoiGianDungToiThieu        = int.Parse(txbThoiGianDungToiThieu.Text);
                tsDTO.ThoiGianHuyVe            = int.Parse(txbThoiGianHuyVe.Text);
                tsDTO.ThoiGianChamNhatKhiDatVe = int.Parse(txbThoiGianChamNhatKhiDatVe.Text);
                tsDTO.ThoiGianBayToiThieu      = int.Parse(txbThoiGianBayToiThieu.Text);

                //3. Thêm vào DBn
                bool kq = tsBUS.CapNhatThamSo(tsDTO);
                if (kq == false)
                {
                    MessageBox.Show("Thêm Hạng vé thất bại. Vui lòng kiểm tra lại dũ liệu! \n", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("Thêm Hạng vé thành công", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            else
            {
                MessageBox.Show("Vui lòng kiểm tra lại dữ liệu!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#2
0
        //Cập nhật tham số
        public bool CapNhatThamSo(TSDTO ts)
        {
            string query = string.Empty;

            query += "UPDATE [ThamSo] SET ";
            query += "[ThoiGianBayToiThieu] = @ThoiGianBayToiThieu, [SoLuongSanBayTrungGianToiDa] = @SoLuongSanBayTrungGianToiDa, ";
            query += "[ThoiGianDungToiDa] = @ThoiGianDungToiDa, [ThoiGianDungToiThieu] = @ThoiGianDungToiThieu, ";
            query += "[ThoiGianChamNhatKhiDatVe] = @ThoiGianChamNhatKhiDatVe, [ThoiGianHuyVe] = @ThoiGianHuyVe";
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {
                    cmd.Connection  = con;
                    cmd.CommandType = System.Data.CommandType.Text;
                    cmd.CommandText = query;
                    cmd.Parameters.AddWithValue("@ThoiGianBayToiThieu", ts.ThoiGianBayToiThieu);
                    cmd.Parameters.AddWithValue("@SoLuongSanBayTrungGianToiDa", ts.SoLuongSanBayTrungGianToiDa);
                    cmd.Parameters.AddWithValue("@ThoiGianDungToiDa", ts.ThoiGianDungToiDa);
                    cmd.Parameters.AddWithValue("@ThoiGianDungToiThieu", ts.ThoiGianDungToiThieu);
                    cmd.Parameters.AddWithValue("@ThoiGianChamNhatKhiDatVe", ts.ThoiGianChamNhatKhiDatVe);
                    cmd.Parameters.AddWithValue("@ThoiGianHuyVe", ts.ThoiGianHuyVe);
                    try
                    {
                        con.Open();
                        cmd.ExecuteNonQuery();
                        con.Close();
                        con.Dispose();
                    }
                    catch (Exception ex)
                    {
                        ts.Error = ex.Message.Remove(0, 65).Trim();
                        con.Close();
                        return(false);
                    }
                }
            }
            return(true);
        }
示例#3
0
        public bool CapNhatThamSo(TSDTO ts)
        {
            bool re = tsDAL.CapNhatThamSo(ts);

            return(re);
        }