public ResponseBase Delete(int manv) { try { db = new QMSEntities(); var result = new ResponseBase(); var nv = db.NHANVIENs.FirstOrDefault(x => x.MANV == manv); if (nv == null) { result.IsSuccess = false;; result.Errors.Add(new Error() { MemberName = "Delete", Message = "Dữ liệu bạn đang thao tác đã bị xóa hoặc không tồn tại. Vui lòng kiểm tra lại !." }); } else { db.NHANVIENs.Remove(nv); db.SaveChanges(); result.IsSuccess = true; } return(result); } catch (Exception ex) { throw ex; } }
public PagedList <EvaluateDetailModel> GetList(int type, int startIndexRecord, int pageSize, string sorting) { try { db = new Models.QMSEntities(); var pageNumber = (startIndexRecord / pageSize) + 1; if (string.IsNullOrEmpty(sorting)) { sorting = "Index DESC"; } var objs = db.Q_EvaluateDetail.Where(x => !x.IsDeleted && x.EvaluateId == type).OrderBy(sorting).Select(x => new EvaluateDetailModel() { Id = x.Id, EvaluateId = x.EvaluateId, Index = x.Index, Name = x.Name, Note = x.Note, IsDefault = x.IsDefault, Icon = x.Icon }).ToList(); return(new PagedList <EvaluateDetailModel>(objs, pageNumber, pageSize)); } catch (Exception ex) { throw ex; } }
public List <WaitingModel_N> GetViewAllWaitingList_N(int maquay) { db = new QMSEntities(); if (maquay == 0) { return(db.XULYYCs.Select(x => new WaitingModel_N() { MAPHIEU = x.MAPHIEU, User = x.NHANVIEN.TENNV, Quay = x.THIETBI.QUAY.TENQUAY, GLAYPHIEU = x.GLAYPHIEU, GDENQUAY = x.GDENQUAY }).ToList()); } else if (maquay > 0) { return(db.XULYYCs.Where(x => x.THIETBI.MAQUAY == maquay).Select(x => new WaitingModel_N() { MAPHIEU = x.MAPHIEU, User = x.NHANVIEN.TENNV, Quay = x.THIETBI.QUAY.TENQUAY, GLAYPHIEU = x.GLAYPHIEU, GDENQUAY = x.GDENQUAY }).ToList()); } return(null); }
public List <QUAY> GetQuay(bool showall) { db = new QMSEntities(); var list = new List <QUAY>(); var objs = db.QUAYs.ToList(); if (objs.Count > 0) { if (showall) { list.Add(new QUAY() { MAQUAY = 0, TENQUAY = "Chọn tất cả" }); } list.AddRange(objs); } else { list.Add(new QUAY() { MAQUAY = -1, TENQUAY = "không có dữ liệu" }); } return(list); }
public List <QuayModel> GetQuayInfo() { db = new QMSEntities(); var returnObjs = new List <QuayModel>(); try { var objs = db.LOGONs.Where(x => x.MATT == eStatus.Login).Distinct().Select(x => new QuayModel() { MaQuay = x.THIETBI.MAQUAY ?? 0, MaTB = x.MATB ?? 0, MaNV = x.MANV ?? 0, TenQuay = x.THIETBI.QUAY.TENQUAY }).ToList(); if (objs != null && objs.Count > 0) { foreach (var item in objs) { if (returnObjs.FirstOrDefault(x => x.MaQuay == item.MaQuay) == null && !string.IsNullOrEmpty(item.TenQuay)) { returnObjs.Add(item); } } } } catch (Exception) { } return(returnObjs.OrderBy(x => x.MaQuay).ToList()); }
public bool ChuyenQuay(QuayModel toQuay, int number, int matb, int manv) { try { db = new QMSEntities(); var xlyc = db.XULYYCs.Where(x => x.MAPHIEU == number && (x.MATT == eStatus.Procesing || x.MATT == eStatus.Waiting)); //if (xlyc != null) //{ // xlyc.MATT = eStatus.Done; // xlyc.GKETTHUC = DateTime.Now; //} var nghiepvu = db.NV_NGHIEPVU.OrderBy(x => x.UUTIEN).FirstOrDefault(x => x.MANV == toQuay.MaNV); var newObj = new XULYYC(); newObj.MAPHIEU = number; newObj.MANVU = nghiepvu.MANVU; newObj.MANVUT = nghiepvu.MANVU; // newObj.GLAYPHIEU = xlyc.GLAYPHIEU; // newObj.GDENQUAY = xlyc.GDENQUAY; newObj.MATT = eStatus.Waiting; newObj.NB = 0; newObj.STT = (db.XULYYCs.Count() + 1); db.XULYYCs.Add(newObj); db.SaveChanges(); return(true); } catch (Exception) { } return(false); }
public List <EvaluateModel> GetList() { db = new Models.QMSEntities(); var parents = db.Q_Evaluate.Where(x => !x.IsDeleted).OrderBy(x => x.Index).Select(x => new EvaluateModel() { Id = x.Id, Name = x.Name, Index = x.Index }).ToList(); if (parents.Count > 0) { var childs = db.Q_EvaluateDetail.Where(x => !x.IsDeleted).Select(x => new EvaluateDetailModel() { Id = x.Id, Name = x.Name, Index = x.Index, EvaluateId = x.EvaluateId, IsDefault = x.IsDefault, Icon = x.Icon }).ToList(); if (childs.Count > 0) { foreach (var item in parents) { item.Childs.AddRange(childs.Where(x => x.EvaluateId == item.Id).OrderBy(x => x.Index).ToList()); } return(parents); } } return(null); }
public List <ReportModel> GetDailyReport() { db = new Models.QMSEntities(); var now = DateTime.Now; List <ReportModel> report = new List <ReportModel>(); report.AddRange(db.NGHIEPVUs.Select(x => new ReportModel() { ServiceId = x.MANVU, ServiceName = x.TENNVU, tc1 = 0, tc2 = 0, tc3 = 0 })); if (report.Count > 0) { var danhgia = db.Q_UserEvaluate.Where(x => (x.GKETTHUC.Value.Day >= now.Day && x.GKETTHUC.Value.Month == now.Month && x.GKETTHUC.Value.Year == now.Year) && (x.GKETTHUC.Value.Day <= now.Day && x.GKETTHUC.Value.Month == now.Month && x.GKETTHUC.Value.Year == now.Year)).ToList(); var nvDG = db.NV_NGHIEPVU.ToList(); List <int> userIds; foreach (var r in report) { userIds = nvDG.Where(x => x.MANVU == r.ServiceId && x.UUTIEN == 1).Select(x => x.MANV).Distinct().ToList(); if (userIds.Count > 0) { r.tc1 = danhgia.Where(x => x.Score == "1_3" && userIds.Contains(x.UserId)).Count(); r.tc2 = danhgia.Where(x => x.Score == "1_1" && userIds.Contains(x.UserId)).Count(); r.tc3 = danhgia.Where(x => x.Score == "1_2" && userIds.Contains(x.UserId)).Count(); } } } return(report); }
public ResponseBase InsertOrUpdate(Q_EvaluateDetail obj) { var rs = new ResponseBase(); try { db = new Models.QMSEntities(); if (obj.Id == 0) { db.Q_EvaluateDetail.Add(obj); rs.IsSuccess = false; } else { var oldObj = Get(obj.Id); if (oldObj != null) { oldObj.EvaluateId = obj.EvaluateId; oldObj.Index = obj.Index; oldObj.Name = obj.Name; oldObj.IsDefault = obj.IsDefault; oldObj.Note = obj.Note; oldObj.Icon = obj.Icon; } } db.SaveChanges(); rs.IsSuccess = true; } catch { } return(rs); }
public ResponseBase Find(string phone, int serviceId) { db = new QMSEntities(); try { var result = new ResponseBase(); var requireObjs = db.YEUCAUs.Where(x => x.MADV == serviceId && x.PHONE.Trim().Equals(phone.Trim())).OrderByDescending(x => x.GIOCAP).FirstOrDefault(); var serviceObj = db.DICHVUs.Where(x => x.MADV == serviceId).FirstOrDefault(); if (requireObjs != null) { result.IsSuccess = true; result.Data = "Khách hàng có SĐT:<b><span class=\"red\"> " + requireObjs.PHONE + "</span></b> <br/>Đã chọn dịch vụ: <b><span class=\"red\">" + serviceObj.TENDV + "</span></b><br/>Được cấp STT: <b><span class=\"red\">" + requireObjs.MAPHIEU + "</span></b><br/>Thời gian phục vụ dự kiến:<b><span class=\"red\"> " + requireObjs.TGPHUCVU_DK.Value.ToString("HH'h : 'mm") + "</span></b>"; } else { result.IsSuccess = false; result.Errors.Add(new Error() { MemberName = "them", Message = "Không tìm thấy thông tin yêu cầu.Vui lòng thử lại." }); } return(result); } catch (Exception ex) { throw ex; } }
public List <WaitingModel> GetViewAllWaitingList() { db = new QMSEntities(); return(db.ViewAllWaitingLists.Select(x => new WaitingModel() { StaffId = x.StaffId, DeskId = x.DeskId, WaitingList = x.WaitingList }).ToList()); }
public List <BooKServiceModel> Get() { db = new QMSEntities(); return(db.Q_BookService.Select(x => new BooKServiceModel() { Id = x.Id, User = x.NHANVIEN.TENNV, KhachHang = x.KhachHang, SoDienThoai = x.SoDienThoai, SoXe = x.SoXe, MaNV = x.MaNV, GioHen = x.GioHen, NgayHen = x.NgayHen }).ToList()); }
public List <ModelSelectItem> Gets() { db = new Models.QMSEntities(); return(db.Q_Evaluate.Where(x => !x.IsDeleted).OrderBy(x => x.Index).Select(x => new ModelSelectItem() { Value = x.Id, Name = x.Name }).ToList()); }
public List <ModelSelectItem> GetServiceSelect() { db = new QMSEntities(); return(db.DICHVUs.OrderBy(x => x.MADV).Select(x => new ModelSelectItem() { Value = x.MADV, Name = x.TENDV }).ToList()); //(Int32)x.MANV có thể gây lỗi }
public List <ModelSelectItem> GetUserSelect() { db = new QMSEntities(); //db.Configuration.ProxyCreationEnabled = false; return(db.NHANVIENs.OrderBy(x => x.MANV).Select(x => new ModelSelectItem() { Value = x.MANV, Name = x.TENNV }).ToList()); //(Int32)x.MANV có thể gây lỗi }
public ResponseBase InsertServiceRequire(YEUCAU model) { db = new QMSEntities(); try { var result = new ResponseBase(); var requireObjs = db.YEUCAUs.Where(x => x.MADV == model.MADV).OrderByDescending(x => x.GIOCAP).ToList(); var serviceObj = db.DICHVUs.Where(x => x.MADV == model.MADV).FirstOrDefault(); double minutes = 0; DateTime time = DateTime.Now; if (serviceObj != null) { model.GIOCAP = time; model.MATT = eStatusName.Wating; if (requireObjs.Count > 0) { model.MAPHIEU = requireObjs[0].MAPHIEU + 1; var processObj = requireObjs.Where(x => eStatusName.Processing == x.MATT).FirstOrDefault(); if (processObj != null) { minutes = TimeSpan.Parse(serviceObj.THOIGIANXULY).TotalMinutes *((int)requireObjs[0].MAPHIEU - (int)processObj.MAPHIEU); } else { minutes = TimeSpan.Parse(serviceObj.THOIGIANXULY).TotalMinutes *requireObjs.Count; } model.TGPHUCVU_DK = time.AddMinutes(minutes); } else { model.MAPHIEU = serviceObj.SOPHIEU.Value + 1; model.TGPHUCVU_DK = time; } db.YEUCAUs.Add(model); db.SaveChanges(); result.IsSuccess = true; result.Data = "Khách hàng có Số điện thoại : " + model.PHONE + " <br/>đã chọn Dịch vụ : " + serviceObj.TENDV + "<br/>được cấp STT : " + model.MAPHIEU + "<br/>Thời gian phục vụ dự kiến :" + model.TGPHUCVU_DK.Value.ToString("HH'h : 'mm"); } else { result.IsSuccess = false; result.Errors.Add(new Error() { MemberName = "them", Message = "Không tìm thấy Dịch Vu theo yêu cầu.Vui lòng thử lại." }); } return(result); } catch (Exception ex) { throw ex; } }
public int GetCurrentDesk(int iCounterId) { db = new QMSEntities(); var obj = db.THIETBIs.FirstOrDefault(x => x.MATB == iCounterId && x.MALTB == 6); if (obj != null) { return(int.Parse(obj.MAQUAY.ToString())); } return(0); }
public bool CallNext(int num, Login login) { //db = new QMSEntities(); //// var xlyc = db.XULYYCs.Where(x => x.MAPHIEU.Value.ToString() == num.ToString() && x.MATB == login.iCounterId && x.MATB == login.iStaffId).FirstOrDefault(); //var xlyc = db.XULYYCs.Where(x => x.MAPHIEU.Value == num && x.MATB == login.iCounterId && x.MANV == login.iStaffId).FirstOrDefault(); //if (xlyc != null) //{ // xlyc.GKETTHUC = DateTime.Now; // xlyc.MATT = eStatus.Done; // //var yc = db.YEUCAUs.FirstOrDefault(x => x.MAPHIEU == num); // //yc.MATT = eStatus.Done; // db.SaveChanges(); // return true; //} //return false; try { db = new QMSEntities(); var xlycs = db.XULYYCs.Where(x => x.MATB == login.iCounterId && x.MANV == login.iStaffId && x.MAPHIEU == num).ToList(); if (xlycs != null) { bool done = false; foreach (var item in xlycs) { item.GKETTHUC = DateTime.Now; item.MATT = eStatus.Done; if (!done) { var newObj = new Q_UserEvaluate(); newObj.UserId = item.MANV ?? 0; newObj.TicketNumber = num; newObj.Score = "0"; newObj.GLAYPHIEU = item.GLAYPHIEU; newObj.GDENQUAY = item.GDENQUAY; newObj.GGIAODICH = item.GGIAODICH; newObj.GKETTHUC = item.GKETTHUC; db.Q_UserEvaluate.Add(newObj); done = true; } } var yc = db.YEUCAUs.FirstOrDefault(x => x.MAPHIEU == num); yc.MATT = eStatus.Done; db.SaveChanges(); return(true); } } catch (Exception) { } return(false); }
public List <UserEvaluateModel> Get(int userId, DateTime from, DateTime to) { db = new QMSEntities(); List <UserEvaluateModel> objs; if (userId == 0) { objs = db.Q_UserEvaluate.Where(x => x.GGIAODICH >= from && x.GGIAODICH <= to).Select(x => new UserEvaluateModel() { Id = x.Id, MAPHIEU = x.TicketNumber, TENNV = x.NHANVIEN.TENNV, DANHGIA = x.Score, GLAYPHIEU = x.GLAYPHIEU, GDENQUAY = x.GDENQUAY, GGIAODICH = x.GGIAODICH, GKETTHUC = x.GKETTHUC, }).ToList(); } else { objs = db.Q_UserEvaluate.Where(x => x.UserId == userId && x.GGIAODICH >= from && x.GGIAODICH <= to).Select(x => new UserEvaluateModel() { Id = x.Id, MAPHIEU = x.TicketNumber, TENNV = x.NHANVIEN.TENNV, DANHGIA = x.Score, GLAYPHIEU = x.GLAYPHIEU, GDENQUAY = x.GDENQUAY, GGIAODICH = x.GGIAODICH, GKETTHUC = x.GKETTHUC, }).ToList(); } if (objs != null && objs.Count > 0) { var evaluateObjs = db.Q_EvaluateDetail.ToList(); foreach (var item in objs) { if (item.DANHGIA == "0") { item.DANHGIA = "không đánh giá"; } else { var arr = item.DANHGIA.Split('_').Select(x => Convert.ToInt32(x)).ToList(); var dt = evaluateObjs.FirstOrDefault(x => x.EvaluateId == arr[0] && x.Id == arr[1]); item.DANHGIA = dt.Name; } } } return(objs); }
public void WriteLogin(int iCounterId, int iStaffId, DateTime dLoginTime) { db = new QMSEntities(); var obj = new LOGON(); obj.MATB = (Int16)iCounterId; obj.MANV = (Int16)iStaffId; obj.NGAY = dLoginTime; obj.GIO = dLoginTime; obj.MATT = eStatus.Login; db.LOGONs.Add(obj); db.SaveChanges(); WriteRequired(iCounterId, "LOGIN", "0", DateTime.Now); }
public PagedList <UserModel> GetList(string keyWord, int searchBy, int startIndexRecord, int pageSize, string sorting) { try { db = new QMSEntities(); db.Configuration.ProxyCreationEnabled = false; if (string.IsNullOrEmpty(sorting)) { sorting = "MANV DESC"; } IQueryable <NHANVIEN> objs = null; //dung kieu IQueryable<> moi OrderBy duoc; List<> ko OrderBy dc var pageNumber = (startIndexRecord / pageSize) + 1; if (!string.IsNullOrEmpty(keyWord)) { objs = db.NHANVIENs.Where(x => x.TENNV.Trim().ToUpper().Contains(keyWord.Trim().ToUpper())).OrderByDescending(x => x.MANV); } else { objs = db.NHANVIENs.OrderByDescending(x => x.MANV); } if (objs != null && objs.Count() > 0) { var NhanVien = objs.Select(x => new UserModel() { MANV = x.MANV, TENNV = x.TENNV, DIACHI = x.DIACHI, GIOITINH = x.GIOITINH, TROGIUP = x.TROGIUP, USERNAME = x.USERNAME, PASSWORD = x.PASSWORD, Hinh = x.Hinh, ChuyenMon = x.ChuyenMon, ChucVu = x.ChucVu, QTCongTac = x.QTCongTac, }); return(new PagedList <UserModel>(NhanVien.ToList(), pageNumber, pageSize)); } else { return(new PagedList <UserModel>(new List <UserModel>(), pageNumber, pageSize)); } } catch (Exception ex) { throw ex; } }
public void CheckRequiredDayPass() { db = new QMSEntities(); var now = DateTime.Now; var objs = db.CounterSofts.Where(x => x.Status != 0 && x.UpdateTime.Value.Year != now.Year && x.UpdateTime.Value.Month != now.Month && x.UpdateTime.Value.Day != now.Day); if (objs != null && objs.Count() > 0) { foreach (var item in objs) { item.Status = 0; } db.SaveChanges(); } }
public void WriteFinishStatus(int iCounterId, bool isViewList) { db = new QMSEntities(); var obj = db.CounterSofts.FirstOrDefault(x => x.CounterSoftId == iCounterId); if (obj != null) { obj.Status = 0; if (isViewList) { obj.Required = ""; } db.SaveChanges(); } }
public List <ReportModel> GetReport(int userId, DateTime from, DateTime to) { db = new Models.QMSEntities(); List <ReportModel> report = new List <ReportModel>(); ReportModel obj; if (userId != 0) { obj = new ReportModel(); obj.Name = db.NHANVIENs.FirstOrDefault(x => x.MANV == userId).TENNV; obj.tc1 = 0; obj.tc2 = 0; obj.tc3 = 0; var danhgia = db.Q_UserEvaluate.Where(x => (x.GKETTHUC.Value.Day >= from.Day && x.GKETTHUC.Value.Month == from.Month && x.GKETTHUC.Value.Year == from.Year) && (x.GKETTHUC.Value.Day <= to.Day && x.GKETTHUC.Value.Month == to.Month && x.GKETTHUC.Value.Year == to.Year) && x.UserId == userId).ToList(); if (danhgia.Count > 0) { obj.tc1 = danhgia.Where(x => x.Score == "1_3").Count(); obj.tc2 = danhgia.Where(x => x.Score == "1_1").Count(); obj.tc3 = danhgia.Where(x => x.Score == "1_2").Count(); } report.Add(obj); } else { var danhgia = db.Q_UserEvaluate.Where(x => (x.GKETTHUC.Value.Day >= from.Day && x.GKETTHUC.Value.Month == from.Month && x.GKETTHUC.Value.Year == from.Year) && (x.GKETTHUC.Value.Day <= to.Day && x.GKETTHUC.Value.Month == to.Month && x.GKETTHUC.Value.Year == to.Year)).ToList(); report.AddRange(db.NHANVIENs.Select(x => new ReportModel() { UserId = x.MANV, Name = x.TENNV, tc1 = 0, tc2 = 0, tc3 = 0 })); if (danhgia.Count > 0) { // var ids = danhgia.Select(x => x.UserId).Distinct(); // report.AddRange(db.NHANVIENs.Select(x => new ReportModel() { UserId = x.MANV, Name = x.TENNV, tc1 = 0, tc2 = 0, tc3 = 0 })); foreach (var item in report) { var objs = danhgia.Where(x => x.UserId == item.UserId).ToList(); if (objs.Count > 0) { item.tc1 = objs.Where(x => x.Score == "1_3").Count(); item.tc2 = objs.Where(x => x.Score == "1_1").Count(); item.tc3 = objs.Where(x => x.Score == "1_2").Count(); } } } } return(report); }
public Login FindUser(string sUsername, string sPassword) { db = new QMSEntities(); Login login = null; var obj = db.NHANVIENs.FirstOrDefault(x => x.USERNAME.Equals(sUsername) && x.PASSWORD.Equals(sPassword)); if (obj != null) { login = new Login(); login.strUsername = sUsername; login.strPassword = sPassword; login.iStaffId = int.Parse(obj.MANV.ToString()); login.strStaffName = obj.TENNV.ToString(); } return(login); }
public Q_CallButtonNext FindButtonClick(Login obj) { db = new QMSEntities(); var data = db.Q_CallButtonNext.FirstOrDefault(x => x.CounterId == obj.iCounterId && x.UserId == obj.iStaffId && x.IsClick); if (data != null) { data.IsClick = false; db.SaveChanges(); return(data); } else { return(null); } }
public bool ChangeStatusToDG(Login obj) { db = new QMSEntities(); var xlYC = db.XULYYCs.FirstOrDefault(x => x.MANV == obj.iStaffId && x.MATB == obj.iCounterId && x.MATT == eStatus.Procesing); if (xlYC != null) { xlYC.MATT = eStatus.Rating; var yc = db.YEUCAUs.FirstOrDefault(x => x.MAPHIEU == xlYC.MAPHIEU); if (yc != null) { yc.MATT = eStatus.Rating; } db.SaveChanges(); return(true); } return(false); }
private bool CheckExists(string keyword, int manv) { try { db = new QMSEntities(); NHANVIEN nv = null; keyword = keyword.Trim().ToUpper(); nv = db.NHANVIENs.FirstOrDefault(x => x.MANV != manv && x.TENNV.Trim().ToUpper().Equals(keyword)); if (nv == null) { return(false); } return(true); } catch (Exception ex) { throw ex; } }
public bool WriteLogout(int iCounterId, int iStaffId, DateTime dLoginTime) { try { db = new QMSEntities(); var obj = db.LOGONs.FirstOrDefault(x => x.MATB == iCounterId && x.MANV == iStaffId && x.MATT == eStatus.Login); if (obj != null) { obj.MATT = eStatus.LogOut; obj.LOGOUTTIME = dLoginTime; db.SaveChanges(); WriteRequired(iCounterId, "LOGOU", "0", dLoginTime); return(true); } } catch (Exception) { } return(false); }
public List <ServiceInfoModel> GetServiceInfo() { db = new QMSEntities(); var result = db.DICHVUs.Select(x => new ServiceInfoModel() { MADV = x.MADV, ServiceName = x.TENDV, TotalCarsWaiting = x.YEUCAUs.Where(c => c.MATT == eStatusName.Wating).Count(), }).ToList(); if (result.Count > 0) { foreach (var item in result) { var obj = db.YEUCAUs.Where(x => x.MATT == eStatusName.Processing && item.MADV == x.MADV).FirstOrDefault(); item.TicketNumberProcessing = (obj != null ? (int)obj.MAPHIEU : 0); } } return(result); }