public bool InsertOrUpdate(string connectString, Q_ServiceLimit model) { using (db = new QMSSystemEntities(connectString)) { if (CheckExists(model) == null) { if (model.Id == 0) { model.CurrentDay = DateTime.Now.ToString("dd/MM/yyyy"); db.Q_ServiceLimit.Add(model); } else { var obj = db.Q_ServiceLimit.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id); if (obj != null) { obj.Quantity = model.Quantity; obj.ServiceId = model.ServiceId; db.SaveChanges(); } else { return(false); } } db.SaveChanges(); return(true); } else { return(false); } } }
public void ResetDailyLoginInfor(string connectString, DateTime date, string IsCopyToNewDay) { using (db = new QMSSystemEntities(connectString)) { try { var yes = db.Q_Login.Where(x => x.StatusId == (int)eStatus.LOGIN).OrderBy(x => x.UserId).ToList(); if (yes.Count > 0) { db.Database.ExecuteSqlCommand("delete Q_Login "); db.Database.ExecuteSqlCommand("DBCC CHECKIDENT('Q_Login', RESEED, 0); "); db.SaveChanges(); List <int> code = new List <int>(); //Q_LoginHistory obj; Q_Login login; var now = DateTime.Now; if (IsCopyToNewDay == "1") { for (int i = 0; i < yes.Count; i++) { //obj = new Q_LoginHistory(); //Parse.CopyObject(yes[i], ref obj); //db.Q_LoginHistory.Add(obj); if (!code.Contains(yes[i].EquipCode)) { login = new Q_Login(); login.Date = now; login.EquipCode = yes[i].EquipCode; login.StatusId = (int)eStatus.LOGIN; login.UserId = yes[i].UserId; db.Q_Login.Add(login); code.Add(yes[i].EquipCode); } } } else { //for (int i = 0; i < yes.Count; i++) //{ // obj = new Q_LoginHistory(); // Parse.CopyObject(yes[i], ref obj); // db.Q_LoginHistory.Add(obj); //} } db.SaveChanges(); } } catch (Exception ex) { } } }
public List <string> Gets(string connectString, int[] counterIds, int userId) { try { using (db = new QMSSystemEntities(connectString)) { List <string> returnStr = new List <string>(); var _id = ("," + userId); var now = DateTime.Now; now = now.AddMinutes(-2); var items = db.Q_TVReadSound.Where(x => counterIds.Contains(x.CounterId.Value) && !x.UsersReaded.Contains(_id) && x.CreatedAt > now).ToList(); if (items.Count > 0) { foreach (var x in items) { x.UsersReaded = (x.UsersReaded + "," + userId); returnStr.Add(x.Sounds); } db.SaveChanges(); } return(returnStr); } } catch (Exception ex) { // throw ex.InnerException; } return(new List <string>()); }
public List <CounterSoftRequireModel> Gets(string connectString, int type) { var list = new List <CounterSoftRequireModel>(); using (db = new QMSSystemEntities(connectString)) { var objs = db.Q_CounterSoftRequire.Where(x => x.TypeOfRequire == type).ToList(); if (objs.Count > 0) { for (int i = 0; i < objs.Count; i++) { list.Add(new CounterSoftRequireModel() { Id = objs[i].Id, Content = objs[i].Content, Type = objs[i].TypeOfRequire, CreatedDate = objs[i].CreatedDate }); if (objs[i].TypeOfRequire == (int)eCounterSoftRequireType.ReadSound || objs[i].TypeOfRequire == (int)eCounterSoftRequireType.SendNextToMainDisplay || objs[i].TypeOfRequire == (int)eCounterSoftRequireType.SendRecallToMainDisplay || objs[i].TypeOfRequire == (int)eCounterSoftRequireType.CheckUserFree) { db.Q_CounterSoftRequire.Remove(objs[i]); } } db.SaveChanges(); } } return(list); }
public ResponseBaseModel DeleteWorkFromTicket(string connectString, int requireWorkDetailId) { var rs = new ResponseBaseModel(); using (db = new QMSSystemEntities(connectString)) { var checkExists = db.Q_DailyRequire_WorkDetail.FirstOrDefault(x => !x.IsDeleted && x.Id == requireWorkDetailId); if (checkExists != null) { var requireObj = db.Q_DailyRequire.FirstOrDefault(x => x.Id == checkExists.DailyRequireId); var workDetail = db.Q_WorkDetail.FirstOrDefault(x => x.Id == checkExists.WorkDetailId); if (requireObj != null && workDetail != null) { requireObj.ServeTimeAllow = requireObj.ServeTimeAllow.Subtract(workDetail.TimeProcess.TimeOfDay); db.Database.ExecuteSqlCommand("delete Q_DailyRequire_WorkDetail where id =" + checkExists.Id); db.SaveChanges(); rs.IsSuccess = true; } else { rs.IsSuccess = false; rs.sms = "Chi tiết công việc đã bị xóa hoặc không tồn tại trong hệ thống. Vui lòng kiểm tra lại!."; } } else { rs.IsSuccess = false; rs.sms = "Phiếu bạn đang chọn không tồn tại công việc này. Vui lòng làm mới lại lưới công việc."; } } return(rs); }
public int Update(Q_Counter model) { using (db = new QMSSystemEntities()) { var obj = db.Q_Counter.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id); if (obj != null) { if (!CheckExists(model)) { obj.ShortName = model.ShortName; obj.Name = model.Name; obj.Index = model.Index; obj.Position = model.Position; obj.Acreage = model.Acreage; db.SaveChanges(); return(model.Id); } else { return(0); } } return(0); } }
public SendSMSModel GetRequireSendSMS() { using (var db = new QMSSystemEntities()) { var report = new SendSMSModel(); report.Phones.AddRange(db.Q_RecieverSMS.Where(x => x.IsActive).Select(x => x.PhoneNumber)); //report.AddRange(db.Q_UserEvaluate.Where(x => !x.IsDeleted && x.SendSMS && !x.Q_User.IsDeleted).Select(x => new SMSModel() { UserName = x.Q_User.Name, ServiceName = x.Q_DailyRequire_Detail.Q_DailyRequire.Q_Service.Name, MajorName = x.Q_DailyRequire_Detail.Q_Major.Name, sms = x.Score })); report.SMS.AddRange(db.Q_UserEvaluate.Where(x => !x.IsDeleted && x.SendSMS && !x.Q_User.IsDeleted).Select(x => new SMSModel() { UserName = x.Q_User.Name, sms = x.Score, MajorName = x.Q_DailyRequire_Detail.Q_Major.Name })); if (report.SMS.Count > 0) { var ThangDGs = db.Q_EvaluateDetail.Where(x => !x.IsDeleted && !x.Q_Evaluate.IsDeleted).ToList(); Q_EvaluateDetail found; int[] arr; for (int i = 0; i < report.SMS.Count; i++) { arr = report.SMS[i].sms.Split('_').Select(x => Convert.ToInt32(x)).ToArray(); if (arr.Length > 1) { found = ThangDGs.FirstOrDefault(x => x.Id == arr[1]); report.SMS[i].sms = (found != null ? found.SmsContent : ""); } } db.Database.ExecuteSqlCommand("update q_userevaluate set sendsms = 0"); db.SaveChanges(); } return(report); } }
public int Update(Q_UserCommandReadSound model) { using (db = new QMSSystemEntities()) { var obj = db.Q_UserCommandReadSound.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id); if (obj != null) { if (!CheckExists(model)) { obj.UserId = model.UserId; obj.CommandId = model.CommandId; obj.Index = model.Index; obj.ReadTemplateId = model.ReadTemplateId; obj.Note = model.Note; db.SaveChanges(); return(obj.Id); } else { return(0); } } return(0); } }
public bool Update(string connectString, Q_Service model) { using (db = new QMSSystemEntities(connectString)) { var obj = db.Q_Service.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id); if (obj != null) { if (!CheckExists(model)) { obj.Name = model.Name; obj.StartNumber = model.StartNumber; obj.Note = model.Note; obj.EndNumber = model.EndNumber; obj.TimeProcess = model.TimeProcess; obj.IsActived = model.IsActived; obj.Code = model.Code; db.SaveChanges(); return(true); } else { return(false); } } return(false); } }
public bool Insert(string connectString, string str, int requireType, int _counterId) { using (db = new QMSSystemEntities(connectString)) { db.Q_CounterSoftRequire.Add(new Q_CounterSoftRequire() { Content = str, TypeOfRequire = requireType, CreatedDate = DateTime.Now }); if (requireType == (int)eCounterSoftRequireType.TVReadSound) { var config = db.Q_Config.FirstOrDefault(x => x.Code == eConfigCode.TVReadSound); if (config != null && config.Value == "1") { db.Q_TVReadSound.Add(new Q_TVReadSound() { CounterId = _counterId, Sounds = str, CreatedAt = DateTime.Now, UsersReaded = "0," }); } } db.SaveChanges(); return(true); } return(false); }
public AndroidModel GetInfoForAndroid(string userName, int getSTT, int getSMS, int getUserInfo) { using (var db = new QMSSystemEntities()) { AndroidModel androidModel = new AndroidModel(); if (getSTT == 1) { var obj = db.Q_DailyRequire_Detail.Where(x => (x.StatusId == (int)eStatus.DAGXL || x.StatusId == (int)eStatus.DANHGIA) && x.ProcessTime.Value.Day == DateTime.Now.Day && x.ProcessTime.Value.Month == DateTime.Now.Month && x.ProcessTime.Value.Year == DateTime.Now.Year && x.Q_User.UserName.Trim().ToUpper().Equals(userName)).FirstOrDefault(); if (obj != null) { var userEval = db.Q_UserEvaluate.FirstOrDefault(x => x.DailyRequireDeId == obj.Id); androidModel.HasEvaluate = (userEval != null ? true : false); androidModel.TicketNumber = obj.Q_DailyRequire.TicketNumber; androidModel.Status = (obj.StatusId == (int)eStatus.DANHGIA ? 1 : 0); } else { androidModel.TicketNumber = 0; } } if (getUserInfo == 1) { androidModel.UserInfo = BLLUser.Instance.GetByUserName(userName); } if (getSMS == 1) { androidModel.SMS = db.Q_CounterSoftRequire.Where(x => x.TypeOfRequire == (int)eCounterSoftRequireType.SendSMS).Select(x => x.Content).ToList(); db.Database.ExecuteSqlCommand("delete Q_CounterSoftRequire where TypeOfRequire = 3"); db.SaveChanges(); } return(androidModel); } }
public ResponseBase Delete(string connectString, int Id) { var rs = new ResponseBase(); using (db = new QMSSystemEntities(connectString)) { var obj = db.Q_RecieverSMS.FirstOrDefault(x => !x.IsActive && x.Id == Id); if (obj != null) { db.Q_RecieverSMS.Remove(obj); db.SaveChanges(); rs.IsSuccess = true; rs.Errors.Add(new Error() { MemberName = "Thông báo", Message = "Xóa thành công." }); } else { rs.IsSuccess = false; rs.Errors.Add(new Error() { MemberName = "Thông báo", Message = "Số điện thoại này đang được sử dụng hoặc không còn tồn tại trong hệ thống. Vui lòng kiểm tra lại!." }); } } return(rs); }
public bool Update(Q_Equipment model) { using (db = new QMSSystemEntities()) { var obj = db.Q_Equipment.FirstOrDefault(x => !x.IsDeleted && x.Id == model.Id); if (obj != null) { if (!CheckExists(model)) { obj.Code = model.Code; obj.Name = model.Name; obj.Position = model.Position; obj.EquipTypeId = model.EquipTypeId; obj.CounterId = model.CounterId; obj.StatusId = model.StatusId; obj.EndTime = model.EndTime; obj.Note = model.Note; db.SaveChanges(); return(true); } else { return(false); } } return(false); } }
public ResponseBase InsertOrUpdate(string connectString, Q_RecieverSMS model) { using (db = new QMSSystemEntities(connectString)) { try { var rs = new ResponseBase(); if (CheckExists(model.Id, model.PhoneNumber.Trim().ToUpper())) { rs.IsSuccess = false; rs.Errors.Add(new Error() { MemberName = "Insert", Message = "Số điện thoại này đã được sử dụng. Vui lòng nhập Số điện thoại khác !." }); } else { Q_RecieverSMS obj; if (model.Id == 0) { obj = new Q_RecieverSMS(); Parse.CopyObject(model, ref obj); db.Q_RecieverSMS.Add(model); rs.IsSuccess = true; } else { obj = db.Q_RecieverSMS.FirstOrDefault(m => m.Id == model.Id); if (obj == null) { rs.IsSuccess = false; rs.Errors.Add(new Error() { MemberName = "Update", 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 { obj.UserIds = model.UserIds; obj.PhoneNumber = model.PhoneNumber; obj.Note = model.Note; obj.IsActive = model.IsActive; obj.UserIds = model.UserIds; rs.IsSuccess = true; } } if (rs.IsSuccess) { db.SaveChanges(); rs.IsSuccess = true; } } return(rs); } catch (Exception ex) { throw ex; } } }
public ResponseBase InsertOrUpdate(string connectString, Q_Evaluate obj) { using (db = new QMSSystemEntities(connectString)) { var rs = new ResponseBase(); try { if (obj.Id == 0) { db.Q_Evaluate.Add(obj); rs.IsSuccess = false; } else { var oldObj = db.Q_Evaluate.FirstOrDefault(x => x.Id == obj.Id);; if (oldObj != null) { oldObj.Index = obj.Index; oldObj.Name = obj.Name; oldObj.Note = obj.Note; } } db.SaveChanges(); rs.IsSuccess = true; } catch { } return(rs); } }
public void AutoLogin(string connectString, string listAuto) { using (var db = new QMSSystemEntities(connectString)) { var listUser = listAuto.Split(',').ToArray(); if (listUser != null && listUser.Length > 0) { DateTime now = DateTime.Now; var logins = (from x in db.Q_Login where x.StatusId == (int)eStatus.LOGIN select x).ToList(); for (int i = 0; i < listUser.Length; i++) { var info = listUser[i].Split('-').Select(x => Convert.ToInt32(x)).ToArray(); if (info.Length == 2) { var found = logins.FirstOrDefault(x => x.UserId == info[0]); if (found == null) { db.Q_Login.Add(new Q_Login() { UserId = info[0], EquipCode = info[1], StatusId = (int)eStatus.LOGIN, Date = now }); } } } db.SaveChanges(); } } }
public bool Copy(List <int> Ids, int userId) { try { using (db = new QMSSystemEntities()) { var src = db.Q_UserCmdRegister.Where(x => !x.IsDeleted && Ids.Contains(x.Id)).ToList(); if (src.Count > 0) { Q_UserCmdRegister obj; for (int i = 0; i < src.Count; i++) { obj = new Q_UserCmdRegister(); obj.UserId = userId; obj.CmdParamId = src[i].CmdParamId; obj.ActionParamId = src[i].ActionParamId; obj.Param = src[i].Param; obj.Index = src[i].Index; obj.Note = src[i].Note; db.Q_UserCmdRegister.Add(obj); } db.SaveChanges(); return(true); } } } catch (Exception) { } return(false); }
//public List<ModelSelectItem> GetLookUp(string connectString) //{ // using (db = new QMSSystemEntities(connectString)){ // return db.Q_ReadTemp_Detail.Where(x => !x.IsDeleted).Select(x => new ModelSelectItem() { Id = x.Id, Name = x.Name }).ToList(); //} public int Insert(string connectString, Q_ReadTemp_Detail obj) { using (db = new QMSSystemEntities(connectString)){ db.Q_ReadTemp_Detail.Add(obj); db.SaveChanges(); return(obj.Id); } }
public int Insert(Q_CommandParameter obj) { using (db = new QMSSystemEntities()){ db.Q_CommandParameter.Add(obj); db.SaveChanges(); return(obj.Id); } }
public int Insert(Q_Status obj) { using (db = new QMSSystemEntities()){ db.Q_Status.Add(obj); db.SaveChanges(); return(obj.Id); } }
public int Insert(string connectString, Q_ActionParameter obj) { using (db = new QMSSystemEntities(connectString)){ db.Q_ActionParameter.Add(obj); db.SaveChanges(); return(obj.Id); } }
//public List<ModelSelectItem> GetLookUp() //{ // using (db = new QMSSystemEntities()){ // return db.Q_EquipTypeProcess.Select(x => new ModelSelectItem() { Id = x.Id, Name = x.Name }).ToList(); //} public int Insert(Q_EquipTypeProcess obj) { using (db = new QMSSystemEntities()){ db.Q_EquipTypeProcess.Add(obj); db.SaveChanges(); return(obj.Id); } }
public int Insert(string connectString, Q_Status obj) { using (db = new QMSSystemEntities(connectString)){ db.Q_Status.Add(obj); db.SaveChanges(); return(obj.Id); } }
public ResponseBase InsertOrUpdate(string connectString, UserMajorModel model) { using (db = new QMSSystemEntities(connectString)) { try { var rs = new ResponseBase(); if (CheckExists(model)) { rs.IsSuccess = false; rs.Errors.Add(new Error() { MemberName = "Insert", Message = "Nhân viên này đã được phân công nghiệp vụ này. Vui lòng chọn nghiệp vụ khác !." }); } else { Q_UserMajor obj; if (model.Id == 0) { obj = new Q_UserMajor(); Parse.CopyObject(model, ref obj); db.Q_UserMajor.Add(obj); rs.IsSuccess = true; } else { obj = db.Q_UserMajor.FirstOrDefault(m => m.Id == model.Id); if (obj == null) { rs.IsSuccess = false; rs.Errors.Add(new Error() { MemberName = "Update", 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 { obj.Index = model.Index; obj.MajorId = model.MajorId; obj.UserId = model.UserId; rs.IsSuccess = true; } } if (rs.IsSuccess) { db.SaveChanges(); rs.IsSuccess = true; } } return(rs); } catch (Exception ex) { throw ex; } } }
public ResponseBase InsertOrUpdate(string connectString, MajorModel model) { using (db = new QMSSystemEntities(connectString)) { try { var rs = new ResponseBase(); if (CheckExists(model.Id, model.Name.Trim().ToUpper())) { rs.IsSuccess = false; rs.Errors.Add(new Error() { MemberName = "Insert", Message = "Tên nghiệp vụ này đã được sử dụng. Vui lòng nhập Tên khác !." }); } else { Q_Major obj; if (model.Id == 0) { obj = new Q_Major(); Parse.CopyObject(model, ref obj); db.Q_Major.Add(obj); rs.IsSuccess = true; } else { obj = db.Q_Major.FirstOrDefault(m => m.Id == model.Id); if (obj == null) { rs.IsSuccess = false; rs.Errors.Add(new Error() { MemberName = "Update", 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 { obj.Name = model.Name; obj.IsShow = model.IsShow; obj.Note = model.Note; rs.IsSuccess = true; } } if (rs.IsSuccess) { db.SaveChanges(); rs.IsSuccess = true; } } return(rs); } catch (Exception ex) { throw ex; } } }
public bool Login(Q_LoginHistory obj) { using (db = new QMSSystemEntities()) { db.Q_LoginHistory.Add(obj); db.SaveChanges(); return(true); } }
public int AddFile(string connectString, Q_Video model) { using (var db = new QMSSystemEntities(connectString)) { db.Q_Video.Add(model); db.SaveChanges(); return(model.Id); } }
public int Insert(Q_ReadTemplate obj) { using (db = new QMSSystemEntities()) { db.Q_ReadTemplate.Add(obj); db.SaveChanges(); return(obj.Id); } }
/// <summary> /// process Login logout of counter /// </summary> /// <param name="userId"></param> /// <param name="equipCode"></param> /// <param name="date"></param> /// <returns></returns> public int CounterLoginLogOut(int userId, int equipCode, DateTime date) { int num = 8888; try { using (db = new QMSSystemEntities()) { var obj = db.Q_Login.FirstOrDefault(x => x.StatusId == (int)eStatus.LOGIN && (x.UserId == userId || x.EquipCode == equipCode)); if (obj == null) { // chua log obj = new Q_Login() { UserId = userId, EquipCode = equipCode, StatusId = (int)eStatus.LOGIN, Date = date }; db.Q_Login.Add(obj); num = 9999; } else { if (obj.EquipCode == equipCode && obj.UserId == userId) { // allready login => logout obj.LogoutTime = date; obj.StatusId = (int)eStatus.LOGOUT; var last = db.Q_DailyRequire_Detail.Where(x => x.Q_DailyRequire.PrintTime.Year == date.Year && x.Q_DailyRequire.PrintTime.Month == date.Month && x.Q_DailyRequire.PrintTime.Day == date.Day && x.UserId == userId && x.EquipCode == equipCode && x.StatusId == (int)eStatus.DAGXL); if (last != null && last.Count() > 0) { foreach (var item in last) { item.StatusId = (int)eStatus.HOTAT; item.EndProcessTime = DateTime.Now; } } num = 8888; } else { // login on other counter // obj.LogoutTime = date; // obj.StatusId = (int)eStatus.LOGOUT; // var newobj = new Q_Login() { UserId = userId, EquipCode = equipCode, StatusId = (int)eStatus.LOGIN, Date = date }; // db.Q_Login.Add(newobj); num = 7777; } } db.SaveChanges(); } } catch (Exception) { } return(num); }
public int Insert(Q_UserEvaluate obj) { using (var db = new QMSSystemEntities()) { db.Q_UserEvaluate.Add(obj); db.SaveChanges(); return(obj.Id); } }