示例#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 txtI_TextChanged(object sender, EventArgs e)
        {
            int tongtien = 0;

            giave1 = 0;
            int       giaveloai1;
            Chuyenbay chuyenbay = dt.Chuyenbays.Where(s => s.MaCB == label3.Text).FirstOrDefault();

            if (chuyenbay != null)
            {
                string a   = chuyenbay.MaCB.ToString();
                Ve     ve1 = dt.Ves.Where(s => s.MaCB == a.ToString()).FirstOrDefault();
                if (ve1 != null)
                {
                    giave1 = int.Parse(ve1.Giave);
                    giave1 = int.Parse(ve1.Giave);
                }
                if (txtI.Text == "")
                {
                    if (txtII.Text != "")
                    {
                        giaveloai1      = (giave2 * int.Parse(txtII.Text.Trim()) * 80) / 100;
                        tongtien        = giaveloai1;
                        lbTongTien.Text = tongtien.ToString();
                    }
                    else
                    {
                        lbTongTien.Text = "0";
                    }
                    return;
                }
                giaveloai1      = giave1 * int.Parse(txtI.Text.Trim());
                tongtien        = int.Parse(lbTongTien.Text);
                tongtien       += giaveloai1;
                lbTongTien.Text = tongtien.ToString();
                dt.SaveChanges();
                Form3_Load(sender, e);
            }
        }
示例#3
0
        private void txtII_TextChanged(object sender, EventArgs e)
        {
            QLBCMBEntities3 dt = new QLBCMBEntities3();

            giave2 = 0;
            int       giaveloai2, tongtien;
            Chuyenbay chuyenbay = dt.Chuyenbays.Where(s => s.MaCB == label3.Text).FirstOrDefault();

            if (chuyenbay != null)
            {
                string a   = chuyenbay.MaCB.ToString();
                Ve     ve1 = dt.Ves.Where(s => s.MaCB == a.ToString()).FirstOrDefault();

                giave2 = int.Parse(ve1.Giave);
                if (txtII.Text == "")
                {
                    if (txtI.Text != "")
                    {
                        giaveloai2      = giave1 * int.Parse(txtI.Text.Trim());
                        tongtien        = giaveloai2;
                        lbTongTien.Text = tongtien.ToString();
                    }
                    else
                    {
                        lbTongTien.Text = "0";
                    }
                    return;
                }
                giaveloai2      = (giave2 * int.Parse(txtII.Text.Trim())) * 80 / 100;
                tongtien        = int.Parse(lbTongTien.Text);
                tongtien       += giaveloai2;
                lbTongTien.Text = tongtien.ToString();
                // hoadon.Tongtien = tongtien;
                //hoadon.MaNV = txtmahd.Text;
                dt.SaveChanges();
                Form3_Load(sender, e);
            }
        }