示例#1
0
文件: Form11.cs 项目: ngochien1999/QL
 private void gunaButton1_Click(object sender, EventArgs e)
 {
     using (QLBCMBEntities2 quanli = new QLBCMBEntities2())
     {
         Chuyenbay cb   = new Chuyenbay();;
         string    macb = quanli.Chuyenbays.Max(p => p.MaCB);
         macb = macb.Substring(2, macb.Length - 2);
         if (int.Parse(macb) < 9)
         {
             macb = "CB0" + (int.Parse(macb) + 1);
         }
         else
         {
             macb = "CB" + (int.Parse(macb) + 1);
         }
         cb.MaCB    = macb;
         cb.Ngaybay = dtngay.Value;
         cb.MaMB    = cbMayBay.SelectedValue.ToString();
         TimeSpan time = TimeSpan.Parse(tbgiobay.Text);
         cb.Thoigianbay = time;
         quanli.Chuyenbays.Add(cb);
         quanli.SaveChanges();
         CTchuyenbay ct   = new CTchuyenbay();;
         string      matb = quanli.CTchuyenbays.Max(p => p.MaTB);
         matb = matb.Substring(2, matb.Length - 2);
         if (int.Parse(matb) < 9)
         {
             matb = "TB0" + (int.Parse(matb) + 1);
         }
         else
         {
             matb = "TB" + (int.Parse(matb) + 1);
         }
         ct.MaCB = macb;
         ct.MaTB = matb;
         TimeSpan time1 = TimeSpan.Parse(dtThoiGiandung.Text);
         ct.Thoigiandung = time;
         ct.SBtrunggian  = cbTrungGian.SelectedValue.ToString();
         quanli.CTchuyenbays.Add(ct);
         quanli.SaveChanges();
         Tuyenbay tb = new Tuyenbay();
         tb.MaTB  = matb;
         tb.SBdi  = cbdi.SelectedValue.ToString();
         tb.SBden = cbden.SelectedValue.ToString();
         quanli.Tuyenbays.Add(tb);
         quanli.SaveChanges();
         MessageBox.Show("Da them");
     }
     this.Close();
 }
示例#2
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);
                }
            }
        }
示例#3
0
文件: Form9.cs 项目: ngochien1999/QL
        private void gunaButton6_Click(object sender, EventArgs e)
        {
            {
                if (!kiemtra())
                {
                    return;
                }
                using (QLBCMBEntities2 quanli = new QLBCMBEntities2())
                {
                    string manv       = quanli.Nhanviens.Max(p => p.MaNV);
                    string ma         = manv.Substring(2, manv.Length - 2);
                    int    manhanvien = int.Parse(ma) + 1;
                    if (manhanvien <= 9)
                    {
                        manv = "NV0" + manhanvien;
                    }
                    else
                    {
                        manv = "NV" + manhanvien;
                    }
                    Nhanvien nv = new Nhanvien();
                    nv.MaNV   = manv;
                    nv.Hoten  = txtten.Text;
                    nv.SĐT    = txtsdt.Text;
                    nv.Diachi = txtdiachi.Text;
                    nv.CMND   = int.Parse(txtcmnd.Text);
                    quanli.Nhanviens.Add(nv);
                    quanli.SaveChanges();

                    Form9_Load(sender, e);
                }
            }
        }
示例#4
0
 private void gunaButton3_Click(object sender, EventArgs e)
 {
     using (QLBCMBEntities2 quanli = new QLBCMBEntities2())
     {
         quanli.deletemb(mamb);
         quanli.SaveChanges();
         MessageBox.Show("đã xóa", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Information);
         Form10_Load(sender, e);
     }
 }
示例#5
0
文件: Form9.cs 项目: ngochien1999/QL
        private void gunaButton4_Click(object sender, EventArgs e)
        {
            {
                if (manv == "")
                {
                    MessageBox.Show("Hãy chọn nhân viên cần sửa!");
                    return;
                }
                using (QLBCMBEntities2 quanli = new QLBCMBEntities2())
                {
                    Nhanvien nv = quanli.Nhanviens.FirstOrDefault(p => p.MaNV == manv);

                    nv.Hoten  = txtten.Text;
                    nv.SĐT    = txtsdt.Text;
                    nv.Diachi = txtdiachi.Text;
                    nv.CMND   = int.Parse(txtcmnd.Text);
                    quanli.SaveChanges();
                    MessageBox.Show("Sua thanh cong!");
                    Form9_Load(sender, e);
                }
            }
        }