public int Insert(tblResumeData resumeData) { try { using (var dbContext = new PMSEntities()) { resumeData.ResumeId = Guid.NewGuid(); dbContext.tblResumeDatas.Add(resumeData); foreach (var obj in resumeData.tblEducations) { obj.ResumeId = resumeData.ResumeId; obj.EducationId = Guid.NewGuid(); dbContext.tblEducations.Add(obj); } dbContext.SaveChanges(); } return(1); } catch (Exception ex) { return(0); } }
public List <Vehicle_Parking> GetAllVehicles() { using (PMSEntities db = new PMSEntities()) { return(db.Vehicle_Parking.ToList()); } }
public static List <ClusterModel> GetNSCForChart(int lineId, TimeSpan timeStart, TimeSpan timeEnd, string date) { try { var db = new PMSEntities(); var clusters = BLLCluster.GetAllByLineId(lineId); if (clusters != null && clusters.Count > 0) { var ids = clusters.Select(x => x.Id); var tdns = db.TheoDoiNgays.Where(x => !x.Chuyen.IsDeleted && !x.Cum.IsDeleted && x.Date == date && x.MaChuyen == lineId && ids.Contains(x.CumId)).ToList(); foreach (var item in clusters) { var tang = tdns.Where(x => x.CumId == item.Id && x.Time >= timeStart && x.Time <= timeEnd && x.CommandTypeId == (int)eCommandRecive.ProductIncrease && x.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(x => x.ThanhPham); var giam = tdns.Where(x => x.CumId == item.Id && x.Time >= timeStart && x.Time <= timeEnd && x.CommandTypeId == (int)eCommandRecive.ProductReduce && x.ProductOutputTypeId == (int)eProductOutputType.KCS).Sum(x => x.ThanhPham); tang = tang - giam; item.KCS = tang > 0 ? tang : 0; } return(clusters); } } catch (Exception ex) { } return(null); }
public void DeleteWorkSpace(WorkSpace ws) { //Setup a fake HttpRequest Mock <HttpContextBase> moqContext = new Mock <HttpContextBase>(); Mock <HttpRequestBase> moqRequest = new Mock <HttpRequestBase>(); Mock <HttpPostedFileBase> moqPostedFile = new Mock <HttpPostedFileBase>(); moqRequest.Setup(r => r.Files.Count).Returns(0); moqContext.Setup(x => x.Request).Returns(moqRequest.Object); //arrange var controller = new HomeController(); PMSEntities db = new PMSEntities(); ws.ID = 1; var work_id = ws.ID; WorkSpace workspace = db.WorkSpaces.Find(work_id); db.WorkSpaces.Remove(workspace); controller.ControllerContext = new ControllerContext(moqContext.Object, new RouteData(), controller); var validationResults = TestModelHelper.ValidateModel(controller, workspace); //act var redirectRoute = controller.Index() as RedirectToRouteResult; //assert Assert.IsNotNull(redirectRoute); Assert.AreEqual("Index", redirectRoute.RouteValues["action"]); //Assert.AreEqual("Home", redirectRoute.RouteValues["controller"]); Assert.AreEqual(0, validationResults.Count); }
public List <AddPhaseQuantitiesModel> GetPhaseDayInfo(List <int> assignIds, int phaseType, DateTime date) { var rs = new List <AddPhaseQuantitiesModel>(); using (var db = new PMSEntities()) { rs.AddRange(db.P_PhaseDaily.Where(x => x.CreatedDate.Day == date.Day && x.CreatedDate.Month == date.Month && x.CreatedDate.Year == date.Year && assignIds.Contains(x.AssignId) && x.P_Phase.Type == phaseType) .OrderByDescending(x => x.CreatedDate).Select(x => new AddPhaseQuantitiesModel() { AssignId = x.AssignId, PhaseId = x.PhaseId, LineName = x.Chuyen_SanPham.Chuyen.TenChuyen, Date = x.CreatedDate, Quantity = x.Quantity, CommandTypeId = x.CommandTypeId, strCommandType = (x.CommandTypeId == (int)eCommandRecive.ProductIncrease ? "Tăng" : "Giảm") })); for (int i = 0; i < rs.Count; i++) { rs[i].strDate = rs[i].Date.ToString("d/M/yyyy HH:mm"); } } return(rs); }
public static ResponseBase Update(P_MonthlyProductionPlans proObj) { var result = new ResponseBase(); try { var db = new PMSEntities(); var obj = db.P_MonthlyProductionPlans.FirstOrDefault(x => !x.IsDeleted && x.Id == proObj.Id); if (obj != null) { obj.LK_TH = proObj.LK_TH; obj.LK_TC = proObj.LK_TC; obj.LK_BTP = proObj.LK_BTP; db.SaveChanges(); result.IsSuccess = true; } } catch (Exception) { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Lỗi", msg = "Lỗi không cập nhật được thông tin." }); } return(result); }
public static List <CompletionPhase_DailyModel> GetDetailInDay(string date, int commoId) { try { var db = new PMSEntities(); return(db.P_CompletionPhase_Daily.Where(x => !x.IsDeleted && x.Date == date && x.P_AssignCompletion.CommoId == commoId).Select(x => new CompletionPhase_DailyModel() { Id = x.Id, AssignId = x.AssignId, CommandTypeId = x.CommandTypeId, CommoName = x.P_AssignCompletion.SanPham.TenSanPham, CompletionPhaseId = x.CompletionPhaseId, PhaseName = x.P_CompletionPhase.Name, Quantity = x.Quantity, Date = x.Date, CreatedDate = x.CreatedDate, //Time = x.CreatedDate.TimeOfDay, TypeName = x.CommandTypeId == (int)eCommandRecive.ProductIncrease ? "Tăng" : "Giảm" }).OrderByDescending(x => x.CreatedDate).ToList()); } catch (Exception ex) { } return(new List <CompletionPhase_DailyModel>()); }
public List <ModelSelectItem> GetNSNgayCuaChuyen(int LineId) { try { using (var db = new PMSEntities()) { var now = DateTime.Now.ToString("d/M/yyyy"); if (LineId != 0) { return(db.Chuyen_SanPham.Where(x => !x.IsDelete && !x.HideForever && !x.SanPham.IsDelete && x.MaChuyen == LineId) .OrderBy(x => x.STTThucHien) .Select(x => new ModelSelectItem() { Value = x.STT, Data = x.STT, Name = x.SanPham.TenSanPham }).ToList()); } } return(null); } catch (Exception ex) { throw ex; } }
public List <NhapSLModel> GetDayInfo(int LineId, string date) { try { using (var db = new PMSEntities()) { if (LineId != 0) { return(db.NangXuats.Where(x => !x.IsDeleted && !x.Chuyen_SanPham.IsDelete && !x.Chuyen_SanPham.HideForever && !x.Chuyen_SanPham.SanPham.IsDelete && x.Chuyen_SanPham.MaChuyen == LineId && x.Ngay == date) .OrderBy(x => x.Chuyen_SanPham.STTThucHien) .Select(x => new NhapSLModel() { cspId = x.STTCHuyen_SanPham, ERR = (x.SanLuongLoi - x.SanLuongLoiGiam), TC = (x.BTPThoatChuyenNgay - x.BTPThoatChuyenNgayGiam), DinhMuc = x.DinhMucNgay, LK_TC = x.Chuyen_SanPham.LuyKeBTPThoatChuyen, KCS = (x.ThucHienNgay - x.ThucHienNgayGiam), LK_KCS = x.Chuyen_SanPham.LuyKeTH, ColorName = x.Chuyen_SanPham.P_Color.Name, ProName = x.Chuyen_SanPham.SanPham.TenSanPham, SizeName = x.Chuyen_SanPham.P_Size.Name }).ToList()); } } return(null); } catch (Exception ex) { throw ex; } }
public static List <ProductModel> Gets(int floorId, int All) { try { using (var db = new PMSEntities()) { var query = db.SanPhams.Where(x => !x.IsDelete); if (All != 1) { query = query.Where(x => x.Floor.Value == floorId); } return(query.OrderBy(x => x.MaSanPham).Select(x => new ProductModel() { MaSanPham = x.MaSanPham, TenSanPham = x.TenSanPham, DinhNghia = x.DinhNghia, DonGia = x.DonGia, DonGiaCM = x.DonGiaCM, Floor = x.Floor ?? 0, ProductionTime = x.ProductionTime }).ToList()); } } catch (Exception) { } return(null); }
public static ResponseBase Delete(int Id) { var result = new ResponseBase(); try { var db = new PMSEntities(); var lineShift = db.P_LineWorkingShift.FirstOrDefault(x => !x.IsDeleted && x.Id == Id); if (lineShift != null) { lineShift.IsDeleted = true; db.SaveChanges(); result.IsSuccess = true; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Xóa thành công." }); } else { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Lỗi", msg = "Không tìm thấy thông tin." }); } } catch (Exception) { } return(result); }
public IEnumerable <Order> GetOrder() { IList <Order> orders = db.Orders.ToList <Order>(); List <Order> orders1 = new List <Order>(); using (var context = new PMSEntities()) { var query = from st in context.Orders select st; } foreach (var p in orders) { Order List = new Order() { OrderId = p.OrderId, ProductId = p.ProductId, ProductQuantity = p.ProductQuantity, UserId = p.UserId, BookingOn = p.BookingOn, DeliveredOn = p.DeliveredOn, }; orders1.Add(List); } return(orders1); }
public ResponseBase Update(List <P_ReadPercentOfLine> items) { var result = new ResponseBase(); try { db = new PMSEntities(); if (items != null && items.Count > 0) { var ids = items.Select(x => x.Id).ToArray(); var objs = db.P_ReadPercentOfLine.Where(x => !x.IsDeleted && ids.Contains(x.Id)); foreach (var itemObj in objs) { var obj = items.FirstOrDefault(x => x.Id == itemObj.Id); if (obj != null) { itemObj.ReadPercent_KCSInventoryId = obj.ReadPercent_KCSInventoryId; } itemObj.ReadPercent_KCSInventoryId = obj.ReadPercent_KCSInventoryId == 0 ? null : obj.ReadPercent_KCSInventoryId; } } db.SaveChanges(); result.IsSuccess = true; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Lưu thành công." }); } catch (Exception ex) { } return(result); }
public int Update(tblResumeData resumeData) { try { using (var dbContext = new PMSEntities()) { dbContext.tblResumeDatas.Attach(resumeData); dbContext.Entry(resumeData).State = EntityState.Modified; foreach (var obj in resumeData.tblEducations) { if (obj.Id != 0) { dbContext.tblEducations.Attach(obj); dbContext.Entry(obj).State = EntityState.Modified; } else { obj.ResumeId = resumeData.ResumeId; obj.EducationId = Guid.NewGuid(); dbContext.tblEducations.Add(obj); } } dbContext.SaveChanges(); } return(1); } catch (Exception ex) { return(0); } }
/// <summary> /// Insert phân công hoàn tất /// </summary> /// <param name="csp"></param> /// <returns></returns> public static ResponseBase Insert(P_AssignCompletion csp) { var result = new ResponseBase(); try { var db = new PMSEntities(); db.P_AssignCompletion.Add(csp); db.SaveChanges(); result.IsSuccess = true; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Lưu Phân công thành công." }); } catch (Exception ex) { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Lỗi Lưu Phân Công", msg = "Lưu Phân công cho Chuyền bị lỗi.\n" + ex.Message }); } return(result); }
public List <ErrorModel> GetErrors(int cspId, string ngay) { using (var db = new PMSEntities()) { var errors = db.Errors.Where(x => !x.IsDeleted && !x.GroupError.IsDeleted).Select(x => new ErrorModel() { Id = x.Id, Code = x.Code, Name = x.Name, GroupName = x.GroupError.Name, PhaseName = x.P_Phase.Name, Quantity = 0 }).OrderBy(x => x.Code).ToList(); if (errors.Count > 0) { var errsInDay = db.TheoDoiNgays.Where(x => ngay == x.Date && x.ErrorId.HasValue && x.STTChuyenSanPham == cspId).ToList(); if (errsInDay.Count > 0) { foreach (var item in errors) { int tang = errsInDay.Where(x => x.ErrorId == item.Code && x.CommandTypeId == (int)eCommandRecive.ErrorIncrease).Sum(x => x.ThanhPham); tang = tang - errsInDay.Where(x => x.ErrorId == item.Code && x.CommandTypeId == (int)eCommandRecive.ErrorReduce).Sum(x => x.ThanhPham); item.Quantity = tang; } } } return(errors); } }
public List <ClientDataModel> getCleints() { try { using (var dbContext = new PMSEntities()) { return(dbContext.tblInwardWOes.Select(x => new ClientDataModel() { ClientName = x.ClientName, Address1 = x.Address1, Address2 = x.Address2, State = x.State, PinCode = x.PinCode, ContactPerson1 = x.ContactPerson1, ContactPerson2 = x.ContactPerson2, Mobile1 = x.Mobile1, Mobile2 = x.Mobile2, Email1 = x.Email1, Email2 = x.Email2, }).Distinct().ToList()); } } catch (Exception ex) { } return(new List <ClientDataModel>()); }
public static List <LineModel> GetLines(int floorId) { try { var db = new PMSEntities(); var list = new List <LineModel>(); return(db.Chuyens.Where(x => !x.IsDeleted && !x.Floor.IsDeleted && x.FloorId == floorId).Select(x => new LineModel() { MaChuyen = x.MaChuyen, TenChuyen = x.TenChuyen, Code = x.Code, DinhNghia = x.DinhNghia, LaoDongDinhBien = x.LaoDongDinhBien, IdDen = x.IdDen, IdDenNangSuat = x.IdDenNangSuat, IdTyLeDoc = x.IdTyLeDoc, IntSTT = x.IntSTT, Floor = x.Floor, Sound = x.Sound, STTReadNS = x.STTReadNS, }).ToList()); } catch (Exception ex) { } return(new List <LineModel>()); }
public static ResponseBase FindAccount(string userName, string password) { var result = new ResponseBase(); try { using (var db = new PMSEntities()) { var user = db.TaiKhoans.FirstOrDefault(x => x.UserName.Trim().ToUpper().Equals(userName.Trim().ToUpper()) && x.Password.Trim().ToUpper().Equals(password.Trim().ToUpper())); if (user != null) { result.IsSuccess = true; result.Data = user; } else { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Đăng Nhập", msg = "Tên Đăng Nhập hoặc Mật Khẩu không đúng." }); } } } catch (Exception ex) { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Lỗi Đăng Nhập", msg = "Lỗi: trong quá trình kiểm tra đăng nhập. " + ex.Message }); } return(result); }
public string FindConfigValue(int appId, string configName) { var value = string.Empty; try { var db = new PMSEntities(); dynamic cf = db.Config_App.FirstOrDefault(x => x.AppId == appId && x.Config.Name.Trim().ToUpper().Equals(configName)); if (cf == null) { cf = db.Configs.FirstOrDefault(x => x.IsActive && x.Name.Trim().ToUpper().Equals(configName)); if (cf != null) { value = cf.ValueDefault.Trim(); } } else { value = cf.Value.Trim(); } } catch (Exception) { } return(value); }
public static ResponseBase Delete(int Id) { var result = new ResponseBase(); try { var db = new PMSEntities(); var MAIL_SCHEDULE = db.MAIL_SCHEDULE.FirstOrDefault(x => !x.IsDeleted && x.Id == Id); if (MAIL_SCHEDULE != null) { MAIL_SCHEDULE.IsDeleted = true; db.SaveChanges(); result.IsSuccess = true; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Xóa thành công." }); } else { result.IsSuccess = false; result.Messages.Add(new Message() { Title = "Thông Báo", msg = "Không tìm thấy thông tin bạn đang thao tác." }); } } catch (Exception ex) { throw ex; } return(result); }
public List <AppConfigModel> GetAll(int appId) { var configs = new List <AppConfigModel>(); try { var db = new PMSEntities(); configs.AddRange(db.Configs.Where(x => x.IsActive).Select(x => new AppConfigModel() { Id = x.Id, Name = x.Name, DisplayName = x.DisplayName, Value = x.ValueDefault, Description = x.Description }).ToList()); var configApp = db.Config_App.Where(x => x.AppId == appId).ToList(); if (configs.Count > 0 && configApp.Count > 0) { foreach (var item in configApp) { var obj = configs.FirstOrDefault(x => x.Id == item.ConfigId); if (obj != null) { obj.Value = item.Value; } } } } catch (Exception) { } return(configs); }
public List <ModelSelectItem> GetHistoryPhase(int assignId, int phaseId) { var rs = new List <ModelSelectItem>(); using (var db = new PMSEntities()) { rs.AddRange((from p in db.P_PhaseDaily where p.AssignId == assignId && p.PhaseId == phaseId select p).ToList() .Select(p => new ModelSelectItem() { Id = p.Id, Name = p.CreatedDate.ToString("dd/MM/yyyy"), Data = p.Quantity, Date = p.CreatedDate, Value = p.CommandTypeId }).OrderByDescending(x => x.Date) .GroupBy(p => p.Name).Select(p => new ModelSelectItem { Name = p.Key, Data = p.Where(x => x.Value == (int)eCommandRecive.ProductIncrease).Sum(x => x.Data), Value = p.Where(x => x.Value == (int)eCommandRecive.ProductReduce).Sum(x => x.Data), Date = p.FirstOrDefault().Date })); } return(rs); }
public static List <LineModel> GetWorkingTime() { try { var db = new PMSEntities(); var shifts = db.Shifts.OrderBy(c => c.TimeStart).ToList(); if (shifts != null && shifts.Count > 0) { var chuyenIds = shifts.Select(x => x.MaChuyen).Distinct(); var Lines = db.Chuyens.Where(x => !x.IsDeleted && chuyenIds.Contains(x.MaChuyen)).Select(x => new LineModel() { MaChuyen = x.MaChuyen, TenChuyen = x.TenChuyen }).OrderBy(x => x.MaChuyen).ToList(); foreach (var line in Lines) { line.WorkingTimes = ProcessShift(shifts.Where(x => x.MaChuyen == line.MaChuyen).ToList()); } return(Lines); } return(null); } catch (Exception ex) { throw ex; } }
public ModelSelectItem GetLKPhase(int phaseId, int cspId) { var rs = new ModelSelectItem() { Id = 0, Value = 0 }; using (var db = new PMSEntities()) { var phaseLog = db.P_Phase_Assign_Log.FirstOrDefault(x => x.AssignId == cspId && x.PhaseId == phaseId); if (phaseLog != null) { rs.Id = phaseLog.Quantity; rs.Value = phaseLog.Chuyen_SanPham.LuyKeTH; rs.Name = phaseLog.Chuyen_SanPham.Chuyen.TenChuyen; } else { var csp = db.Chuyen_SanPham.FirstOrDefault(x => x.STT == cspId); if (csp != null) { rs.Value = csp.LuyKeTH; rs.Name = csp.Chuyen.TenChuyen; } } } return(rs); }
public static ResponseBase DeleteShift(int Id) { var result = new ResponseBase(); try { var db = new PMSEntities(); var shift = db.P_WorkingShift.FirstOrDefault(x => !x.IsDeleted && x.Id == Id); if (shift != null) { shift.IsDeleted = true; db.SaveChanges(); result.IsSuccess = true; result.Messages.Add(new Message() { msg = "Lưu thông tin thành công.", Title = "Thông Báo" }); } } catch (Exception) { result.IsSuccess = false; result.Messages.Add(new Message() { msg = "Lưu thông tin bị lỗi.", Title = "Lỗi" }); } return(result); }
public Vehicle_Parking GetById(string id) { using (PMSEntities db = new PMSEntities()) { return(db.Vehicle_Parking.Find(id)); } }
public static SelectListAndDefaultModel GetFloorForComBoBox() { var rs = new SelectListAndDefaultModel(); try { var db = new PMSEntities(); var floors = db.Floors.ToList(); var defaultValue = 0; if (floors.Count > 0) { foreach (var item in floors) { rs.SelectList.Add(item); defaultValue = item.IsDefault ? item.IdFloor : defaultValue; } } else { rs.SelectList.Add(new Floor() { IdFloor = 0, Name = "Không có thông tin Lầu" }); } rs.DefaultValue = defaultValue; } catch (Exception) { } return(rs); }
public static ResponseBase InsertOrUpdate(ThoiGianTinhNhipDoTT obj) { var rs = new ResponseBase(); try { var db = new PMSEntities(); var old = db.ThoiGianTinhNhipDoTTs.FirstOrDefault(x => x.Ngay == obj.Ngay && x.MaChuyen == obj.MaChuyen); if (old == null) { db.ThoiGianTinhNhipDoTTs.Add(obj); } else { old.ThoiGianBatDau = obj.ThoiGianBatDau; } db.SaveChanges(); rs.IsSuccess = true; } catch (Exception) { rs.IsSuccess = false; } return(rs); }
public static List <VideoScheduleModel> Gets(int LineId) { try { var db = new PMSEntities(); var objs = db.P_PlayVideoShedule.Where(x => !x.IsDeleted && x.LineId == LineId).Select(x => new VideoScheduleModel() { Id = x.Id, TimeStart = x.TimeStart, TimeEnd = x.TimeEnd, LineId = x.LineId, IsActive = x.IsActive }).ToList(); if (objs.Count > 0) { var ids = objs.Select(x => x.Id); var detailObjs = db.P_PlayVideoSheduleDetail.Where(x => !x.IsDeleted && !x.P_VideoLibrary.IsDeleted && ids.Contains(x.VideoSheduleId)).ToList(); if (detailObjs.Count > 0) { foreach (var item in objs) { item.Detail.AddRange(detailObjs.Where(x => x.VideoSheduleId == item.Id)); } } } return(objs); } catch (Exception) { } return(new List <VideoScheduleModel>()); }