Exemplo n.º 1
0
        public bool insertVeChuyenBay(VeChuyenBay VCB)
        {
            string sql = "insert into VECHUYENBAY(MaChuyenBay, HangVe, GiaTien, HoTen, CMND, SDT, Email)" +
                         " VALUES(@MaChuyenBay, @HangVe, @GiaTien, @HoTen, @CMND, @SDT, @Email)";

            using (SqlConnection con = dc.getConnect())
            {
                try
                {
                    cmd = new SqlCommand(sql, con);
                    con.Open();
                    cmd.Parameters.Add("@MaChuyenBay", SqlDbType.VarChar).Value = VCB.MaChuyenBay;
                    cmd.Parameters.Add("@HangVe", SqlDbType.NVarChar).Value     = VCB.HangVe;
                    cmd.Parameters.Add("@GiaTien", SqlDbType.Money).Value       = VCB.GiaTien;
                    cmd.Parameters.Add("@HoTen", SqlDbType.NVarChar).Value      = VCB.HoTen;
                    cmd.Parameters.Add("@CMND", SqlDbType.VarChar).Value        = VCB.CMND;
                    cmd.Parameters.Add("@SDT", SqlDbType.VarChar).Value         = VCB.SDT;
                    cmd.Parameters.Add("@Email", SqlDbType.VarChar).Value       = VCB.Email;
                    cmd.ExecuteNonQuery();
                    con.Close();

                    return(true);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message, "Thông báo lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(false);
                }
            }
        }
Exemplo n.º 2
0
        private void btPrintTicket_Click(object sender, EventArgs e)
        {
            if (CheckInput())
            {
                DialogResult result = MessageBox.Show("Vé đã in sẽ không được thay đổi, bạn chắc chắn thông tin đã chính xác", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
                if (result == DialogResult.Yes)
                {
                    if (btEdit.Text != "Hủy" && btSell.Text != "Hủy")
                    {
                        if (bllPDC.getTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString()) == "Chưa xuất vé")
                        {
                            bllPDC.UpdateTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString(), "Đã xuất vé");
                        }
                        else
                        {
                            lbNotify.Visible   = true;
                            lbNotify.ForeColor = Color.Red;
                            lbNotify.Text      = "Vé đã được xuất hoặc bị hủy";
                            return;
                        }
                    }
                    else
                    if (btEdit.Text == "Hủy")
                    {
                        if (bllPDC.getTrangThai(dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString()) == "Chưa xuất vé")
                        {
                            PhieuDatCho PDC = new PhieuDatCho();

                            PDC.MaPhieuDatCho = dataGridPhieuDat.Rows[Id].Cells["colMaPhieuDat"].Value.ToString();
                            PDC.MaChuyenBay   = tbMaChuyenBay.Text;
                            PDC.HangVe        = cbHangVe.Text;
                            PDC.GiaTien       = decimal.Parse(lbGiaTien.Text);
                            PDC.TrangThai     = "Đã xuất vé";
                            PDC.HoTen         = tbHoTen.Text;
                            PDC.CMND          = tbCMND.Text;
                            PDC.SDT           = tbSDT.Text;
                            PDC.Email         = tbEmail.Text;
                            bllPDC.UpdatePhieuDatCho(PDC);

                            btEdit.Text    = "Chỉnh sửa";
                            btSell.Enabled = true;
                        }
                        else
                        {
                            lbNotify.Visible   = true;
                            lbNotify.ForeColor = Color.Red;
                            lbNotify.Text      = "Vé đã được xuất hoặc bị hủy";
                            btEdit.Text        = "Chỉnh sửa";
                            btSell.Enabled     = true;
                            return;
                        }
                    }
                    else if (btSell.Text == "Hủy")
                    {
                        LockCotrol();
                        btSell.Text    = "Bán vé";
                        btEdit.Enabled = true;
                    }

                    VeChuyenBay VCB = new VeChuyenBay();

                    VCB.MaChuyenBay = tbMaChuyenBay.Text;
                    VCB.HangVe      = cbHangVe.Text;
                    VCB.GiaTien     = decimal.Parse(lbGiaTien.Text);
                    VCB.HoTen       = tbHoTen.Text;
                    VCB.CMND        = tbCMND.Text;
                    VCB.SDT         = tbSDT.Text;
                    VCB.Email       = tbEmail.Text;

                    if (bllVCB.insertVeChuyenBay(VCB))
                    {
                        lbNotify.Visible   = true;
                        lbNotify.Text      = "Thành công";
                        lbNotify.ForeColor = Color.FromArgb(8, 186, 29);

                        DanhSachGhe DSG = new DanhSachGhe();
                        DSG.MaChuyenBay = VCB.MaChuyenBay;
                        DSG.HangVe      = VCB.HangVe;
                        DSG.SoGheTrong  = bllDSG.getSoGheTrong(tbMaChuyenBay.Text, cbHangVe.Text) - 1;

                        bllDSG.UpdateSoGheTrong(DSG);
                        tbMaChuyenBay.Text = "";
                        tbHoTen.Text       = "";
                        tbSDT.Text         = "";
                        tbCMND.Text        = "";
                        tbEmail.Text       = "";
                        lbGiaTien.Text     = "0";
                    }
                    else
                    {
                        lbNotify.ForeColor = Color.Red;
                        lbNotify.Text      = "Đã có lỗi xảy ra, vui lòng thử lại sau";
                    }
                }
            }
        }
Exemplo n.º 3
0
 public bool insertVeChuyenBay(VeChuyenBay VCB)
 {
     return(dalVCB.insertVeChuyenBay(VCB));
 }