/// <summary> /// this function copy the model for edit /// </summary> /// <param name="model"></param> the model should be edited /// <returns></returns> returns if the copy is successfull public Boolean Edit(RoutInfoModel model) { Boolean result = true; try { IsEdit = true; _model = model; } catch (Exception ex) { result = false; } return(result); }
/// <summary> /// this function convert the model to table form /// </summary> /// <param name="model"></param> the convertable model /// <returns></returns> returns the converted table public DataLayer.PP_RoutInfo ConvertToTable(RoutInfoModel model) { DataLayer.PP_RoutInfo tbl = new DataLayer.PP_RoutInfo(); tbl.RoutID = model.RoutID; tbl.RoutName = model.RoutName; tbl.WorkStationID = model.WorkStationID; tbl.RoutTypeID = model.RoutTypeID; tbl.PartID = model.PartID; tbl.YearID = model.YearID; tbl.BranchID = model.BranchID; tbl.UserID = model.UserID; tbl.RegisteredDate = model.RegisteredDate; tbl.IsActived = model.IsActived; return(tbl); }
/// <summary> /// this function copy the models to save /// </summary> /// <param name="model"></param> the copyable model /// <returns></returns> returns if the copy is successfull public Boolean Add(RoutInfoModel model) { Boolean result = true; try { _model = model; _model.BranchID = CRMStaticData.StaticData.getBranchID; _model.RegisteredDate = CRMStaticData.StaticData.getRegisteredDate; _model.UserID = CRMStaticData.StaticData.getUserID; _model.YearID = CRMStaticData.StaticData.getYearID; _model.IsActived = 1; } catch (Exception ex) { Console.WriteLine(ex.ToString()); } return(result); }
/// <summary> /// this function conver the table form to model /// </summary> /// <param name="tbl"></param> the covertable table /// <returns></returns>the converted model public RoutInfoModel ConvertToModel(DataLayer.PP_RoutInfo tbl) { RoutInfoModel model = new RoutInfoModel(); model.RoutID = tbl.RoutID; model.RoutName = tbl.RoutName; model.WorkStationID = tbl.WorkStationID; model.RoutTypeID = tbl.RoutTypeID; model.PartID = tbl.PartID; model.YearID = tbl.YearID; model.BranchID = tbl.BranchID; model.UserID = tbl.UserID; model.IsActived = (int)tbl.IsActived; model.RegisteredDate = tbl.RegisteredDate; model.PartName = context.MRP_PartInfos.Where(q => q.PartID == tbl.PartID).FirstOrDefault().PartName; model.WorkStationName = context.PP_WorkStationInfos.Where(q => q.WorkStationID == tbl.WorkStationID).FirstOrDefault().WorkStationName; model.RoutTypeName = context.PP_RoutTypeInfos.Where(q => q.RoutTypeID == tbl.RoutTypeID).FirstOrDefault().RoutTypeName; return(model); }