public IHttpActionResult getChucVu(string id) { Models.ChucVu kq = dc.ChucVus.Find(id); if (kq == null) { return(BadRequest()); } Models.CChucVu cv = new Models.CChucVu() { MaCV = kq.MaCV, TenCV = kq.TenCV, status = kq.status, NhanViens = new List <Models.CNhanVien>() { } }; foreach (Models.NhanVien item in kq.NhanViens) { Models.CNhanVien c = new Models.CNhanVien() { MaNV = item.MaNV, TenNV = item.TenNV, Tuoi = item.Tuoi, GioiTinh = item.GioiTinh, DiaChi = item.DiaChi, SoDT = item.SoDT, NgayVaoLam = item.NgayVaoLam, status = item.status }; cv.NhanViens.Add(c); } return(Ok(cv)); }
public Models.ChucVu Default_ChucVu() { EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.ChucVu chucvu = db.ChucVus.FirstOrDefault(x => x.CVID == 1); return(chucvu); }
public void Delete(int _chucvuID) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.ChucVu chucvu = db.ChucVus.FirstOrDefault(x => x.CVID == _chucvuID); db.ChucVus.Remove(chucvu); db.SaveChanges(); db.Dispose(); }
public void Update(int _chucvuID, string _ten) { Models.EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.ChucVu chucvu = db.ChucVus.FirstOrDefault(x => x.CVID == _chucvuID); chucvu.CVTen = _ten; db.SaveChanges(); db.Dispose(); }
public IHttpActionResult put(Models.CChucVu cv) { Models.ChucVu c = dc.ChucVus.Find(cv.MaCV); if (c == null) { return(NotFound()); } c.TenCV = cv.TenCV; dc.SaveChanges(); return(Ok()); }
public IHttpActionResult deleteChucVu(string id) { Models.ChucVu cv = dc.ChucVus.Find(id); if (cv == null) { return(NotFound()); } cv.status = false; dc.SaveChanges(); return(Ok()); }
public void AddChucVu(Models.ChucVu cv) { foreach (var item in DSChucVu) { if (item.ChucVuID == cv.ChucVuID) { return; } } Models.DanhSachChucVu newcv = new Models.DanhSachChucVu { ChucVu = db.ChucVus.Single(c => c.ChucVuID == cv.ChucVuID), NhanVienID = _Employee.NhanVienID }; DSChucVu.Add(newcv); }
public bool Is_Existing(string _ten) { EmployeeManagementEntities db = new EmployeeManagementEntities(); Models.ChucVu chucvu = db.ChucVus.FirstOrDefault(x => x.CVTen.Equals(_ten)); if (chucvu == null) { return(false); } else { return(true); } }
public JsonResult GetListPosition() { List <Models.ChucVu> liposition = new List <Models.ChucVu>(); Database db = new Database(); DataTable dt = db.Query("select * from ChucVu ;"); for (int i = 0; i < dt.Rows.Count; i++) { Models.ChucVu position = new Models.ChucVu(); position.MaChucVu = dt.Rows[i]["MaCV"].ToString(); position.TenChucVu = dt.Rows[i]["TenCV"].ToString(); liposition.Add(position); } return(Json(liposition)); }
public IHttpActionResult postChucVu(Models.CChucVu cv) { if (ModelState.IsValid == false) { return(BadRequest()); } Models.ChucVu c = new Models.ChucVu() { MaCV = c.MaCV, TenCV = c.TenCV, status = true }; dc.ChucVus.Add(c); dc.SaveChanges(); return(Ok()); }
protected void Page_Load(object sender, EventArgs e) { if (this.Page.RouteData.Values["chucvu"] != null) { this.UpdateStatus(); _chucvuID = Convert.ToInt32(Page.RouteData.Values["chucvu"]); Models.ChucVu chucvu = _chucvuEntity.Find(_chucvuID); if (!IsPostBack) { RadTextBoxChucVuTen.Text = chucvu.CVTen; } } else { this.CreateStatus(); } }
protected void Page_Load(object sender, EventArgs e) { if (this.Page.RouteData.Values["chucvu"] != null) { try { int chucvuID = Convert.ToInt32(this.Page.RouteData.Values["chucvu"]); Models.ChucVuEntity chucvuEntity = new Models.ChucVuEntity(); Models.ChucVu chucvu = chucvuEntity.Find(chucvuID); if (chucvu == null) { Response.Redirect("~/ChucVu"); } } catch (Exception) { Response.Redirect("~/ChucVu"); } } }
public void AddEmployee(string Hoten, string Diachi, bool Gioitinh, DateTime?NgaySinh, String Phone1, String Phone2, String CMND, String Email, Models.ChucVu chucvu, string password) { Models.NhanVien nv = new Models.NhanVien { ConNguoi = new Models.ConNguoi { HoTen = Hoten, DiaChi = Diachi, GioiTinh = Gioitinh, NgaySinh = NgaySinh, Phone = Phone1, Phone2 = Phone2, CMND = CMND, Email = Email, MatKhau = password } }; nv.DanhSachChucVus.Add(new Models.DanhSachChucVu { NhanVien = nv, ChucVu = chucvu }); db.NhanViens.InsertOnSubmit(nv); try { db.SubmitChanges(); } catch (Exception ex) { FireHandledExeptionAndLogErorrAsync(ErrorTemplates.GetDBInteractionError(ex)); } }
public void AddPosition(Models.ChucVu a) { Database db = new Database(); db.Insert("insert into ChucVu values (N'" + a.TenChucVu + "'," + a.MucLuong + ");"); }
public static void AppInitialize() { App.Log = new Lib.Logger(new DirectoryInfo(@"Log/")); Models.DBDataContext db = new Models.DBDataContext(); if (!db.DatabaseExists()) { db.CreateDatabase(); Models.ChucVu ChucManager = new Models.ChucVu { Quyen = new Models.Quyen { PhanQuyen = false, HoTroGiaoTiepKH = true, XoaCuocGoi = true, QLTTCaNhanKH = true, SuaTTKH = true, XoaTTKH = true, QLTTNV = false, BaoCaoThongKe = true, QLTTQuaTang = true, XemTTQuaTang = true, XemTTNhanVien = true } }; Models.ChucVu ChucAdmin = new Models.ChucVu { Quyen = new Models.Quyen { PhanQuyen = true, HoTroGiaoTiepKH = false, XoaCuocGoi = false, QLTTCaNhanKH = false, SuaTTKH = false, XoaTTKH = false, QLTTNV = true, BaoCaoThongKe = false, QLTTQuaTang = false, XemTTQuaTang = false, XemTTNhanVien = true } }; Models.ChucVu ChucStaff = new Models.ChucVu { Quyen = new Models.Quyen { PhanQuyen = false, HoTroGiaoTiepKH = true, XoaCuocGoi = true, QLTTCaNhanKH = true, SuaTTKH = false, XoaTTKH = false, QLTTNV = false, BaoCaoThongKe = false, QLTTQuaTang = false, XemTTQuaTang = true, XemTTNhanVien = false } }; db.ChucVus.InsertAllOnSubmit(new List <Models.ChucVu> { ChucManager, ChucAdmin, ChucStaff }); db.LoaiQuanHes.InsertAllOnSubmit(new List <Models.LoaiQuanHe> { new Models.LoaiQuanHe { TenQuanHe = "Vợ" }, new Models.LoaiQuanHe { TenQuanHe = "Chồng" }, new Models.LoaiQuanHe { TenQuanHe = "Cha" }, new Models.LoaiQuanHe { TenQuanHe = "Mẹ" }, new Models.LoaiQuanHe { TenQuanHe = "Ông" }, new Models.LoaiQuanHe { TenQuanHe = "Bà" }, new Models.LoaiQuanHe { TenQuanHe = "Anh" }, new Models.LoaiQuanHe { TenQuanHe = "Chị" }, new Models.LoaiQuanHe { TenQuanHe = "Con" }, new Models.LoaiQuanHe { TenQuanHe = "Cháu" }, new Models.LoaiQuanHe { TenQuanHe = "Em" }, new Models.LoaiQuanHe { TenQuanHe = "Bạn" }, new Models.LoaiQuanHe { TenQuanHe = "Họ Hàng" }, new Models.LoaiQuanHe { TenQuanHe = "Người Quen" } }); db.LoaiCuocGois.InsertAllOnSubmit(new List <Models.LoaiCuocGoi> { new Models.LoaiCuocGoi { TenLoaiCuocGoi = "Yêu cầu" }, new Models.LoaiCuocGoi { TenLoaiCuocGoi = "Thắc mắc" }, new Models.LoaiCuocGoi { TenLoaiCuocGoi = "Phàn nàn" }, }); Models.NhanVien Admin = new Models.NhanVien { ConNguoi = new Models.ConNguoi { HoTen = "Admin được khởi tạo tự động", MatKhau = "123" }, }; Admin.DanhSachChucVus.Add(new Models.DanhSachChucVu { ChucVu = ChucAdmin }); db.NhanViens.InsertOnSubmit(Admin); db.SubmitChanges(); } }