예제 #1
0
        public IHttpActionResult CapNhatSV(CapNhatSinhVien model)
        {
            IHttpActionResult httpActionResult;
            ErrorModel        errors = new ErrorModel();

            TTSV sv = this.db.TTSVs.FirstOrDefault(x => x.Id == model.Id);

            if (sv == null)
            {
                errors.Add("Không tìm thấy lớp");

                // httpActionResult = Ok(errors);
                httpActionResult = new ErrorActionResult(Request, System.Net.HttpStatusCode.NotFound, errors);
            }
            else
            {
                sv.MaSv     = model.MaSv ?? model.MaSv;
                sv.NgaySinh = model.NgaySinh;
                sv.HoTen    = model.HoTen ?? model.HoTen;

                this.db.Entry(sv).State = System.Data.Entity.EntityState.Modified;

                this.db.SaveChanges();

                httpActionResult = Ok(new SinhVien_model(sv));
            }

            return(httpActionResult);
        }
예제 #2
0
        public IHttpActionResult TaoSV(TaoSinhVien model)
        {
            IHttpActionResult httpActionResult;
            ErrorModel        errors = new ErrorModel();

            if (string.IsNullOrEmpty(model.MaSv))
            {
                errors.Add("Mã sinh vien là trường bắt buộc");
            }

            if (errors.Errors.Count == 0)
            {
                TTSV sv = new TTSV();
                sv.MaSv     = model.MaSv;
                sv.HoTen    = model.HoTen;
                sv.NgaySinh = model.NgaySinh;
                sv.lop      = db.TTLOPs.FirstOrDefault(x => x.Id == model.LopId);
                sv          = db.TTSVs.Add(sv);

                this.db.SaveChanges();

                SinhVien_model SV = new SinhVien_model(sv);

                httpActionResult = Ok(SV);
            }
            else
            {
                // httpActionResult = Ok(errors);
                httpActionResult = new ErrorActionResult(Request, System.Net.HttpStatusCode.BadRequest, errors);
            }

            return(httpActionResult);
        }
예제 #3
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            TTSV fTT = new TTSV(null);

            fTT.ShowDialog();
            Show(0, txbSearch.Text);
        }
예제 #4
0
 public SinhVien_model(TTSV ttsv)
 {
     this.Id       = ttsv.Id;
     this.MaSv     = ttsv.MaSv;
     this.HoTen    = ttsv.HoTen;
     this.NgaySinh = ttsv.NgaySinh;
     this.LopId    = ttsv.lop.Id;
 }
예제 #5
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            DataGridViewSelectedRowCollection data = dtgSV.SelectedRows;

            if (data.Count == 1)
            {
                string MSSV = data[0].Cells["MSSV"].Value.ToString();
                //Form2 fTT = new Form2(MSSV);
                //fTT.ShowDialog();
                //Show(0, txbSearch.Text);
                TTSV fTT = new TTSV(MSSV);
                fTT.ShowDialog();
                Show(0, txbSearch.Text);
            }
        }