// Update Quá trình Công tác. private void Update_QTCT(QuaTrinhCongTac quaTrinhCT) { txt_QT_MaDV.Text = quaTrinhCT.MaDV; txt_QT_MaPB.Text = quaTrinhCT.MaPB; txt_QT_TenPB.Text = quaTrinhCT.PhongBan; txt_QT_Congviec.Text = quaTrinhCT.CongViec; txt_QT_Diadiem.Text = quaTrinhCT.DiaDiem; txt_QT_Chucvu.Text = quaTrinhCT.ChucVu; txt_QT_Batdau.Text = quaTrinhCT.BatDau.ToShortDateString(); txt_QT_Ketthuc.Text = quaTrinhCT.KetThuc.ToShortDateString(); //if (maDV == "") //{ // MessageBox.Show("Vui lòng nhập Mã ĐV!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); // return null; //} //else //{ // if (txt_QT_Ketthuc.Text != "") // { // dt_KT = ConvertStringToDate(txt_QT_Ketthuc.Text); // _quaTrinhCT = new QuaTrinhCongTac(maDV, dt_BD, dt_KT, congViec, diaDiem, chucVu, maPB, phongBan, 0); // } // else // _quaTrinhCT = new QuaTrinhCongTac(maDV, dt_BD, congViec, diaDiem, chucVu, maPB, phongBan, 1); // return _quaTrinhCT; //} }
public IHttpActionResult PutQuaTrinhCongTac(byte id, QuaTrinhCongTac quaTrinhCongTac) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != quaTrinhCongTac.ID) { return(BadRequest()); } db.Entry(quaTrinhCongTac).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!QuaTrinhCongTacExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
// Insert Quá trình Công tác. private QuaTrinhCongTac Insert_QTCT() { string maDV = txt_QT_MaDV.Text; string maPB = txt_QT_MaPB.Text; string phongBan = txt_QT_TenPB.Text; string congViec = txt_QT_Congviec.Text; string diaDiem = txt_QT_Diadiem.Text; string chucVu = txt_QT_Chucvu.Text; DateTime dt_BD = ConvertStringToDate(txt_QT_Batdau.Text); DateTime dt_KT; if (maDV == "") { MessageBox.Show("Vui lòng nhập Mã ĐV!", "Thông báo", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } else { if (txt_QT_Ketthuc.Text != "") { dt_KT = ConvertStringToDate(txt_QT_Ketthuc.Text); _quaTrinhCT = new QuaTrinhCongTac(maDV, dt_BD, dt_KT, congViec, diaDiem, chucVu, maPB, phongBan, 0); } else { _quaTrinhCT = new QuaTrinhCongTac(maDV, dt_BD, congViec, diaDiem, chucVu, maPB, phongBan, 1); } return(_quaTrinhCT); } }
public async Task <QuaTrinhCongTac> Update(QuaTrinhCongTac model) { return(await WithConnection(async c => { var obj = await c.GetAsync(model); if (obj == null) { throw new Exception(string.Format("Update id {0} not exist", model.QuaTrinhCongTacId.ToString())); } if (obj.CtrVersion != model.CtrVersion) { throw new Exception(string.Format("Update id {0} have version confict" , model.QuaTrinhCongTacId.ToString())); } model.CtrVersion += 1; var result = await c.UpdateAsync(model); if (result != true) { throw new Exception("Update Fail"); } return model; })); }
public IHttpActionResult GetQuaTrinhCongTac(byte id) { QuaTrinhCongTac quaTrinhCongTac = db.QuaTrinhCongTacs.Find(id); if (quaTrinhCongTac == null) { return(NotFound()); } return(Ok(quaTrinhCongTac)); }
public IHttpActionResult PostQuaTrinhCongTac(QuaTrinhCongTac quaTrinhCongTac) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.QuaTrinhCongTacs.Add(quaTrinhCongTac); db.SaveChanges(); return(CreatedAtRoute("DefaultApi", new { id = quaTrinhCongTac.ID }, quaTrinhCongTac)); }
public async Task <ActionResult> Edit([Bind(Include = "MaCT,MaNKH,ThoiGianBD,ThoiGIanKT,TenCoQuan,TenPhongBan,DiaChiCoQuan,TinhTP,ChucVuCT")] QuaTrinhCongTac quaTrinhCongTac, int manhakhoahoc) { if (ModelState.IsValid) { db.Entry(quaTrinhCongTac).State = EntityState.Modified; await db.SaveChangesAsync(); return(RedirectToAction("Edit", "AdminNhaKhoaHoc", new { id = manhakhoahoc })); } ViewBag.manhakhoahoc = manhakhoahoc; return(View(quaTrinhCongTac)); }
// GET: AdminQuaTrinhCongTac/Details/5 public async Task <ActionResult> Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuaTrinhCongTac quaTrinhCongTac = await db.QuaTrinhCongTacs.FindAsync(id); if (quaTrinhCongTac == null) { return(HttpNotFound()); } return(View(quaTrinhCongTac)); }
public async Task <QuaTrinhCongTac> Insert(QuaTrinhCongTac obj) { return(await WithConnection(async c => { await c.InsertAsync(obj); if (obj.QuaTrinhCongTacId == 0) { throw new Exception("Insert Fail"); } return obj; })); }
public IHttpActionResult DeleteQuaTrinhCongTac(byte id) { QuaTrinhCongTac quaTrinhCongTac = db.QuaTrinhCongTacs.Find(id); if (quaTrinhCongTac == null) { return(NotFound()); } db.QuaTrinhCongTacs.Remove(quaTrinhCongTac); db.SaveChanges(); return(Ok(quaTrinhCongTac)); }
// GET: AdminQuaTrinhCongTac/Edit/5 public async Task <ActionResult> Edit(int?id, int manhakhoahoc) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuaTrinhCongTac quaTrinhCongTac = await db.QuaTrinhCongTacs.FindAsync(id); if (quaTrinhCongTac == null) { return(HttpNotFound()); } ViewBag.manhakhoahoc = manhakhoahoc; return(View(quaTrinhCongTac)); }
// GET: AdminQuaTrinhCongTac/Delete/5 public async Task <ActionResult> Delete(int?id, int manhakhoahoc) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } QuaTrinhCongTac quaTrinhCongTac = await db.QuaTrinhCongTacs.FindAsync(id); if (quaTrinhCongTac == null) { return(HttpNotFound()); } db.QuaTrinhCongTacs.Remove(quaTrinhCongTac); await db.SaveChangesAsync(); return(RedirectToAction("Edit", "AdminNhaKhoaHoc", new { id = manhakhoahoc })); }
public async Task <QuaTrinhCongTac> UpdatePartialBase(QuaTrinhCongTac model, bool checkCtrVersion, params string[] field) { return(await WithConnection(async c => { var obj = await c.GetAsync(model); if (obj == null) { throw new Exception(string.Format("Update id {0} not exist", model.QuaTrinhCongTacId.ToString())); } if (checkCtrVersion == true && obj.CtrVersion != model.CtrVersion) { throw new Exception(string.Format("Update id {0} have version confict" , model.QuaTrinhCongTacId.ToString())); } model.CtrVersion += 1; var list = field.ToList(); list.Add(nameof(QuaTrinhCongTac.CtrVersion)); var partialUpdateMapping = OrmConfiguration .GetDefaultEntityMapping <QuaTrinhCongTac>() .Clone() // clone it if you don't want to modify the default .UpdatePropertiesExcluding(prop => prop.IsExcludedFromUpdates = true, list.ToArray()); var result = await c.UpdateAsync(model, statement => statement.WithEntityMappingOverride(partialUpdateMapping)); if (result != true) { throw new Exception("Update Fail"); } return model; })); }
// QUÁ TRÌNH CÔNG TÁC. public bool Update_QuaTrinhCT(QuaTrinhCongTac quaTrinhCT) { SqlCommand cmd = new SqlCommand(); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add("@MADV", SqlDbType.NVarChar).Value = quaTrinhCT.MaDV; cmd.Parameters.Add("@MAPB", SqlDbType.NVarChar).Value = quaTrinhCT.MaPB; cmd.Parameters.Add("@PHONGBAN", SqlDbType.NVarChar).Value = quaTrinhCT.PhongBan; cmd.Parameters.Add("@BATDAU", SqlDbType.Date).Value = quaTrinhCT.BatDau; cmd.Parameters.Add("@CONGVIEC", SqlDbType.NVarChar).Value = quaTrinhCT.CongViec; cmd.Parameters.Add("@DIADIEM", SqlDbType.NVarChar).Value = quaTrinhCT.DiaDiem; cmd.Parameters.Add("@CHUCVU", SqlDbType.NVarChar).Value = quaTrinhCT.ChucVu; if (quaTrinhCT.ViTri == 0) { cmd.CommandText = "SP_Update_QUATRINHCT_0"; cmd.Parameters.Add("@KETTHUC", SqlDbType.Date).Value = quaTrinhCT.KetThuc; } else { cmd.CommandText = "SP_Update_QUATRINHCT_1"; } cmd.Connection = _conn; try { _conn.Open(); cmd.ExecuteNonQuery(); return(true); } catch { return(false); } finally { _conn.Close(); } }
public frmUpdate(Object obj, int item) { InitializeComponent(); gbThongTin.Visible = false; gbThemThongTin.Visible = false; gbTrinhdo.Visible = false; gbQuatrinhCT.Visible = false; gbDaoTao.Visible = false; gbDiNN.Visible = false; gbKhenThuong.Visible = false; gbKyluat.Visible = false; gbGiadinh.Visible = false; gbTuNhanXet.Visible = false; switch (item) { case 0: this._thongTin = (ThongTin)obj; Update_ThongTin(_thongTin); gbThongTin.Visible = true; break; case 1: this._themThongTin = (ThemThongTin)obj; Update_ThemThongTin(_themThongTin); gbThemThongTin.Visible = true; break; case 2: this._trinhDo = (TrinhDo)obj; Update_TrinhDo(_trinhDo); gbTrinhdo.Visible = true; break; case 3: this._quaTrinhCT = (QuaTrinhCongTac)obj; Update_QTCT(_quaTrinhCT); gbQuatrinhCT.Visible = true; break; case 4: this._daoTaoBD = (DaoTao_BoiDuong)obj; Update_DTBD(_daoTaoBD); gbDaoTao.Visible = true; break; case 5: this._diNuocNgoai = (DiNuocNgoai)obj; Update_DNN(_diNuocNgoai); gbDiNN.Visible = true; break; case 6: this._khenThuong = (KhenThuong)obj; Update_KT(_khenThuong); gbKhenThuong.Visible = true; break; case 7: this._kyLuat = (KyLuat)obj; Update_KL(_kyLuat); gbKyluat.Visible = true; break; case 8: this._giaDinh = (GiaDinh)obj; Update_GD(_giaDinh); gbGiadinh.Visible = true; break; case 9: this._tuNhanXet = (TuNhanXet)obj; Update_TNX(_tuNhanXet); gbTuNhanXet.Visible = true; break; } }
public async Task <QuaTrinhCongTac> UpdatePartial(QuaTrinhCongTac model, params string[] field) { return(await UpdatePartialBase(model, true, field)); }
// QUÁ TRÌNH CÔNG TÁC. public bool Update_QuaTrinhCongTac(QuaTrinhCongTac quaTrinhCT) { return(dal_Update.Update_QuaTrinhCT(quaTrinhCT)); }
private void btnUpdate_Click(object sender, EventArgs e) { switch (_itemValue) { case 0: { _thongTin = new ThongTin(); _thongTin.MaDV = txtMaDV.Text; _thongTin.HoTen = txtHoten.Text; _thongTin.TenKhaiSinh = txtTenKS.Text; _thongTin.BiDanh = txtBidanh.Text; _thongTin.GioiTinh = txtGioitinh.Text; _thongTin.NgaySinh = convertStringToDate(txtNgaysinh.Text); _thongTin.QueQuan = txtQuequan.Text; _thongTin.DiaChi = rtxtDiachi.Text; _thongTin.SDT = txtSDT.Text; _thongTin.Email = txtEmail.Text; _thongTin.DanToc = txtDantoc.Text; _thongTin.TonGiao = txtTongiao.Text; _thongTin.LinkAnh = _linkAnh; _frmUpdate = new frmUpdate(_thongTin, 0); _frmUpdate.Show(); break; } case 1: { _themThongTin = new ThemThongTin(); _themThongTin.MaDV = txt_TTT_MaDV.Text; _themThongTin.NgayVaoDoan = convertStringToDate(txt_TTT_NgayVD.Text); _themThongTin.NoiVaoDoan = txt_TTT_MaDV.Text; _themThongTin.NgayVaoDangL1 = convertStringToDate(txt_TTT_NgayVDL1.Text); _themThongTin.NoiVaoDangL1 = txt_TTT_MaDV.Text; _themThongTin.NgayChinhThucL1 = convertStringToDate(txt_TTT_NgayCTL1.Text); _themThongTin.NoiCongNhanL1 = txt_TTT_MaDV.Text; _themThongTin.NguoiGioiThieuL1 = txt_TTT_MaDV.Text; _frmUpdate = new frmUpdate(_themThongTin, 1); _frmUpdate.Show(); break; } case 2: { _trinhDo = new TrinhDo(); _trinhDo.MaDV = txt_TD_MaDV.Text; _trinhDo.TrinhDoPT = txt_TD_PT.Text; _trinhDo.ChuyenMon = txt_TD_Chuyenmon.Text; _trinhDo.HocVi = txt_TD_Hocvi.Text; _trinhDo.DTHocVi = convertStringToDate(txt_TD_CTHV.Text); _trinhDo.HocHam = txt_TD_Hocham.Text; _trinhDo.DTHocham = convertStringToDate(txt_TD_CTHH.Text); _trinhDo.LyLuanCT = txt_TD_Lyluan.Text; _trinhDo.NgoaiNgu = rtxt_TD_NN.Text; _frmUpdate = new frmUpdate(_trinhDo, 2); _frmUpdate.Show(); break; } case 3: { _quaTrinhCT = new QuaTrinhCongTac(); _quaTrinhCT.MaDV = txt_QT_MaDV.Text; _quaTrinhCT.MaPB = txt_QT_MaPB.Text; _quaTrinhCT.PhongBan = txt_QT_TenPB.Text; _quaTrinhCT.BatDau = convertStringToDate(txt_QT_Batdau.Text); _quaTrinhCT.KetThuc = convertStringToDate(txt_QT_Ketthuc.Text); _quaTrinhCT.CongViec = txt_QT_Congviec.Text; _quaTrinhCT.DiaDiem = txt_QT_Diadiem.Text; _quaTrinhCT.ChucVu = txt_QT_Chucvu.Text; _frmUpdate = new frmUpdate(_quaTrinhCT, 3); _frmUpdate.Show(); break; } case 4: { _daoTaoBD = new DaoTao_BoiDuong(); _daoTaoBD.MaDV = txt_DT_MaDV.Text; _daoTaoBD.BatDau = convertStringToDate(txt_DT_BD.Text); _daoTaoBD.KetThuc = convertStringToDate(txt_DT_KT.Text); _daoTaoBD.TenLop = txt_DT_Tenlop.Text; _daoTaoBD.HinhThuc = txt_DT_Hinhthuc.Text; _daoTaoBD.ChungChi = txt_DT_Chungchi.Text; _frmUpdate = new frmUpdate(_daoTaoBD, 4); _frmUpdate.Show(); break; } case 5: { _diNuocNgoai = new DiNuocNgoai(); _diNuocNgoai.MaDV = txt_DNN_MaDV.Text; _diNuocNgoai.BatDau = convertStringToDate(txt_DNN_BD.Text); _diNuocNgoai.KetThuc = convertStringToDate(txt_DNN_KT.Text); _diNuocNgoai.NoiDung = rtxt_DNN_ND.Text; _diNuocNgoai.DiaDiem = txt_DNN_DD.Text; _frmUpdate = new frmUpdate(_diNuocNgoai, 5); _frmUpdate.Show(); break; } case 6: { _khenThuong = new KhenThuong(); _khenThuong.MaDV = txt_KT_MaDV.Text; _khenThuong.ThoiGian = convertStringToDate(txt_KT_TG.Text); _khenThuong.HinhThuc = txt_KT_Hinhthuc.Text; _khenThuong.CapQD = txt_KT_CapQD.Text; _khenThuong.LyDo = rtxt_KT_Lydo.Text; _frmUpdate = new frmUpdate(_khenThuong, 6); _frmUpdate.Show(); break; } case 7: { _kyLuat = new KyLuat(); _kyLuat.MaDV = txt_KL_MaDV.Text; _kyLuat.ThoiGian = convertStringToDate(txt_KL_TG.Text); _kyLuat.HinhThuc = txt_KL_Hinhthuc.Text; _kyLuat.CapQD = txt_KL_CapQD.Text; _kyLuat.LyDo = rtxt_KL_Lydo.Text; _frmUpdate = new frmUpdate(_kyLuat, 7); _frmUpdate.Show(); break; } case 8: { _giaDinh = new GiaDinh(); _giaDinh.MaDV = txt_GD_MaDV.Text; _giaDinh.QuanHe = txt_GD_QH.Text; _giaDinh.HoTen = txt_GD_Hoten.Text; _giaDinh.NamSinh = txt_GD_Namsinh.Text; _giaDinh.QueQuan = txt_GD_Quequan.Text; _giaDinh.DiaChi = rtxt_GD_Diachi.Text; _frmUpdate = new frmUpdate(_giaDinh, 8); _frmUpdate.Show(); break; } case 9: { _tuNhanXet = new TuNhanXet(); _tuNhanXet.MaDV = txt_TNX_MaDV.Text; _tuNhanXet.PhamChat = txt_TNX_PC.Text; _tuNhanXet.DaoDuc = txt_TNX_DD.Text; _tuNhanXet.NangLuc = txt_TNX_NL.Text; _tuNhanXet.QuanHeQC = txt_TNX_QHQC.Text; _tuNhanXet.KhuyetDiem = txt_TNX_KD.Text; _frmUpdate = new frmUpdate(_tuNhanXet, 9); _frmUpdate.Show(); break; } } }
// QUÁ TRÌNH CÔNG TÁC. public bool Insert_QuaTrinhCongTac(QuaTrinhCongTac quaTrinhCT) { return(dal_Insert.Insert_QuaTrinhCT(quaTrinhCT)); }