Beispiel #1
0
        public static void adddata(SinhVIen sv, van van, vatly vatly, cntt cntt)
        {
            var db = new democontext();

            db.sinhVIens.Add(sv);
            db.SaveChanges();
            if (van != null)
            {
                db.vans.Add(van);
                db.SaveChanges();
            }
            if (vatly != null)
            {
                db.vatlies.Add(vatly);
                db.SaveChanges();
            }
            if (cntt != null)
            {
                db.cntts.Add(cntt);
                db.SaveChanges();
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            var sv = new SinhVIen();

            sv.id    = Guid.NewGuid().ToString();
            sv.hoten = textBox1.Text;
            if (checkBox1.Checked)
            {
                sv.gioitinh = true;
            }
            else
            {
                sv.gioitinh = false;
            }
            sv.ngaysinh = dateTimePicker1.Value;
            var van = new van();

            van.idsv = sv.id;
            van.vhcd = Convert.ToInt64(numericUpDown1.Value);
            van.vhhh = Convert.ToInt64(numericUpDown2.Value);
            var vatly = new vatly();

            vatly.idsv      = sv.id;
            vatly.cohoc     = Convert.ToInt64(numericUpDown3.Value);
            vatly.quanhoc   = Convert.ToInt64(numericUpDown4.Value);
            vatly.dien      = Convert.ToInt64(numericUpDown5.Value);
            vatly.vlhatnhan = Convert.ToInt64(numericUpDown6.Value);
            var cntt = new cntt();

            cntt.idsv   = sv.id;
            cntt.pascal = Convert.ToInt64(numericUpDown7.Value);
            cntt.csap   = Convert.ToInt64(numericUpDown8.Value);
            cntt.sql    = Convert.ToInt64(numericUpDown9.Value);
            SinhVienservice.adddata(sv, van, vatly, cntt);
            DialogResult = DialogResult.OK;
            this.Close();
        }