Пример #1
0
        private void gunaButton6_Click(object sender, EventArgs e)
        {
            {
                if (!kiemtra())
                {
                    return;
                }
                using (QLBCMBEntities2 quanli = new QLBCMBEntities2())
                {
                    string mamb       = quanli.Maybays.Max(p => p.MaMB);
                    string ma         = mamb.Substring(2, mamb.Length - 2);
                    int    manhanvien = int.Parse(ma) + 1;
                    if (manhanvien <= 9)
                    {
                        mamb = "MB0" + manhanvien;
                    }
                    else
                    {
                        mamb = "MB" + manhanvien;
                    }
                    Maybay nv = new Maybay();
                    nv.MaMB     = mamb;
                    nv.TenMB    = txtten.Text;
                    nv.Hang     = cbGT.Text;
                    nv.Gheloai1 = txtI.Text;
                    nv.Gheloai2 = txtII.Text;
                    quanli.Maybays.Add(nv);
                    quanli.SaveChanges();

                    Form10_Load(sender, e);
                }
            }
        }
Пример #2
0
 private void gunaButton3_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("Bạn có muốn xóa hóa đơn này không?", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
     {
         using (QLBCMBEntities3 quanli = new QLBCMBEntities3())
         {
             Maybay hd = quanli.Maybays.FirstOrDefault(p => p.MaMB == mamb);
             if (hd != null)
             {
                 quanli.Maybays.Remove(hd);
                 quanli.SaveChanges();
                 MessageBox.Show("Đã xóa!");
                 Form10_Load(sender, e);
             }
         }
     }
 }
Пример #3
0
        //public void Loadchuyenbay()
        //{
        //    string query = " select * from Tuyenbay";
        //    DataTable data = Connect.Instace.excutequery(query);
        //   dtchuyenbay.DataSource = data;

        //}
        //public void LoadCombox()
        //  {
        //      string query = "select * from Tuyenbay";
        //      DataTable data = Connect.Instace.excutequery(query);
        //      cbdi.DataSource = data;
        //      cbdi.ValueMember = "MaTB";
        //      cbdi.DisplayMember = "SBdi";
        //  }
        private void Form5_Load(object sender, EventArgs e)
        {
            DataTable table = new DataTable();

            table.Columns.Add("MaCB");
            table.Columns.Add("MaMB");
            table.Columns.Add("NgayBay");
            table.Columns.Add("ThoiGianBay");
            table.Columns.Add("GheLoai1");
            table.Columns.Add("GheLoai2");
            using (QLBCMBEntities2 quanli = new QLBCMBEntities2())
            {
                List <Chuyenbay> ds_cb = quanli.Chuyenbays.ToList();
                foreach (var item in ds_cb)
                {
                    Maybay mb = quanli.Maybays.FirstOrDefault(p => p.MaMB == item.MaMB);
                    table.Rows.Add(item.MaCB, item.MaMB, item.Ngaybay, item.Thoigianbay, mb.Gheloai1, mb.Gheloai2);
                }
            }
            gunaDataGridView1.AutoGenerateColumns = false;
            gunaDataGridView1.DataSource          = table;
        }
Пример #4
0
        private void btnLuu_Click(object sender, EventArgs e)
        {
            {
                if (temp)
                {
                    if (!kiemtra())
                    {
                        return;
                    }

                    using (QLBCMBEntities3 quanli = new QLBCMBEntities3())
                    {
                        string mamb       = quanli.Maybays.Max(p => p.MaMB);
                        string ma         = mamb.Substring(2, mamb.Length - 2);
                        int    manhanvien = int.Parse(ma) + 1;
                        if (manhanvien <= 9)
                        {
                            mamb = "MB0" + manhanvien;
                        }
                        else
                        {
                            mamb = "MB" + manhanvien;
                        }
                        Maybay nv = new Maybay();
                        nv.MaMB     = mamb;
                        nv.TenMB    = txtten.Text;
                        nv.Hang     = cbGT.Text;
                        nv.Gheloai1 = txtI.Text;
                        nv.Gheloai2 = txtII.Text;

                        quanli.Maybays.Add(nv);
                        quanli.SaveChanges();

                        Form10_Load(sender, e);
                        clearData();
                        btnthem.Enabled  = true;
                        dtmaybay.Enabled = true;
                    }
                }



                else
                {
                    if (mamb == "")
                    {
                        MessageBox.Show("Hãy chọn máy bay cần sửa!");
                        return;
                    }
                    {
                        using (QLBCMBEntities3 quanli = new QLBCMBEntities3())
                        {
                            if (mamb == "")
                            {
                                MessageBox.Show("Hãy chọn sân bay cần sửa!");
                                return;
                            }

                            using (QLBCMBEntities3 quanli1 = new QLBCMBEntities3())
                            {
                                Maybay nv = quanli1.Maybays.FirstOrDefault(p => p.MaMB == mamb);

                                nv.TenMB    = txtten.Text;
                                nv.Hang     = cbGT.Text;
                                nv.Gheloai1 = txtI.Text;
                                nv.Gheloai2 = txtII.Text;

                                quanli1.SaveChanges();
                                DialogResult dr = MessageBox.Show("Sửa thành công!", "Thông báo",
                                                                  MessageBoxButtons.OK, MessageBoxIcon.Information);
                                Form10_Load(sender, e);
                                clearData();
                                btnthem.Enabled  = true;
                                dtmaybay.Enabled = true;
                            }
                        }
                    }
                }
            }
        }