public void ObterTodosTeste() { BaseDao<ProdutoMap> baseDao = new BaseDao<ProdutoMap>(new Contexto()); IQueryable<ProdutoMap> lista = baseDao.ObterTodos(); Assert.AreNotEqual(lista.Count(),0); }
/// <summary> /// Delete /// </summary> /// <param name="obj">資料物件</param> /// <param name="strFunctionName">Where條件的method name</param> /// <returns></returns> public static StringBuilder Delete(object obj, string strFunctionName = "PK_") { BaseDao objBaseDao = new BaseDao(); StringBuilder strSql = new StringBuilder(); string strTableName = string.Empty; string strTag = "@"; foreach (PropertyInfo objItem in obj.GetType().GetProperties()) { if (objItem.Name == "TABLE_NAME") { strTableName = objItem.GetValue(obj, null).ToString(); } } strSql.AppendLine("DELETE " + strTableName + " "); strSql.AppendLine("WHERE 1=1 "); //若strFunctionName為empty或null,則預設為該物件PK_開頭的method name if (strFunctionName == "PK_") { foreach (MethodInfo objMethod in obj.GetType().GetMethods()) { if (objMethod.Name.Substring(0, 3) == "PK_") { strFunctionName = objMethod.Name; } } } //根據FunctionName的傳入參數組出Where條件 if (!string.IsNullOrEmpty(strFunctionName)) { //取得物件的Funtion foreach (MethodInfo objMethod in obj.GetType().GetMethods()) { if (objMethod.Name == strFunctionName) { foreach (ParameterInfo objParameter in objMethod.GetParameters()) { strSql.AppendLine("AND " + objParameter.Name + " = " + strTag + objParameter.Name + " "); } } } } return strSql; }
public void ObterTeste() { ProdutoMap produto = new ProdutoMap() { Id = Guid.NewGuid(), Tamanho = Catalogo.Tamanhos[3] }; BaseDao<ProdutoMap> baseDao = new BaseDao<ProdutoMap>(new Contexto()); baseDao.Adicionar(produto); var produtoObtido = baseDao.Obter(produto.Id); Assert.AreEqual(produto, produtoObtido); }
public BaseBO(BaseDao <T> dao) { _dao = dao; }
public CourseRepository() { _dao = new BaseDao(); }
public MonitorSendWarnBO(BaseDao <monitor_sendwarn> dao) : base(dao) { }
public AttendanceRepository() { _dao = new BaseDao(); }
public SMC_PackageExtHistoryBO(BaseDao <SMC_PackageExtHistory> dao) : base(dao) { }
private IEnumerable <ms_permissionsassign> IsGroupCodeRightAcsess(string groupCode, int mappingID) { BaseDao context = new BaseDao(); return(context.ms_permissionsassign.Where(c => c.GroupCode == groupCode).AsQueryable()); }
public int UpdateData(SYS_ParameterDto updateDto) { int returnCode = CommonData.DbReturnCode.Succeed; try { using (BaseDao context = new BaseDao()) { sy_parameters _parameters = context.sy_parameters.FirstOrDefault(p => p.ID.Equals(updateDto.Id)); if (_parameters != null) { //Create insert infomation //ItemAdditional VN _parameters.ItemAdditional1 = updateDto.ItemAdditional1; _parameters.ItemAdditional2 = updateDto.ItemAdditional2; _parameters.ItemAdditional3 = updateDto.ItemAdditional3; _parameters.ItemAdditional4 = updateDto.ItemAdditional4; _parameters.ItemAdditional5 = updateDto.ItemAdditional5; _parameters.ItemAdditional6 = updateDto.ItemAdditional6; _parameters.ItemAdditional7 = updateDto.ItemAdditional7; _parameters.ItemAdditional8 = updateDto.ItemAdditional8; _parameters.ItemAdditional9 = updateDto.ItemAdditional9; _parameters.ItemAdditional10 = updateDto.ItemAdditional10; //ItemAdditional EN _parameters.ItemAdditional1EN = updateDto.ItemAdditional1EN; _parameters.ItemAdditional2EN = updateDto.ItemAdditional2EN; _parameters.ItemAdditional3EN = updateDto.ItemAdditional3EN; _parameters.ItemAdditional4EN = updateDto.ItemAdditional4EN; _parameters.ItemAdditional5EN = updateDto.ItemAdditional5EN; _parameters.ItemAdditional6EN = updateDto.ItemAdditional6EN; _parameters.ItemAdditional7EN = updateDto.ItemAdditional7EN; _parameters.ItemAdditional8EN = updateDto.ItemAdditional8EN; _parameters.ItemAdditional9EN = updateDto.ItemAdditional9EN; _parameters.ItemAdditional10EN = updateDto.ItemAdditional10EN; //ItemAdditional JP _parameters.ItemAdditional1JP = updateDto.ItemAdditional1JP; _parameters.ItemAdditional2JP = updateDto.ItemAdditional2JP; _parameters.ItemAdditional3JP = updateDto.ItemAdditional3JP; _parameters.ItemAdditional4JP = updateDto.ItemAdditional4JP; _parameters.ItemAdditional5JP = updateDto.ItemAdditional5JP; _parameters.ItemAdditional6JP = updateDto.ItemAdditional6JP; _parameters.ItemAdditional7JP = updateDto.ItemAdditional7JP; _parameters.ItemAdditional8JP = updateDto.ItemAdditional8JP; _parameters.ItemAdditional9JP = updateDto.ItemAdditional9JP; _parameters.ItemAdditional10JP = updateDto.ItemAdditional10JP; //ItemAdditionalIsActive1 _parameters.ItemAdditionalIsActive1 = updateDto.ItemAdditionalIsActive1; _parameters.ItemAdditionalIsActive2 = updateDto.ItemAdditionalIsActive2; _parameters.ItemAdditionalIsActive3 = updateDto.ItemAdditionalIsActive3; _parameters.ItemAdditionalIsActive4 = updateDto.ItemAdditionalIsActive4; _parameters.ItemAdditionalIsActive5 = updateDto.ItemAdditionalIsActive5; _parameters.ItemAdditionalIsActive6 = updateDto.ItemAdditionalIsActive6; _parameters.ItemAdditionalIsActive7 = updateDto.ItemAdditionalIsActive7; _parameters.ItemAdditionalIsActive8 = updateDto.ItemAdditionalIsActive8; _parameters.ItemAdditionalIsActive9 = updateDto.ItemAdditionalIsActive8; _parameters.ItemAdditionalIsActive10 = updateDto.ItemAdditionalIsActive10; //ItemAdditionalIsRequired _parameters.ItemAdditionalIsRequired1 = updateDto.ItemAdditionalIsRequired1; _parameters.ItemAdditionalIsRequired2 = updateDto.ItemAdditionalIsRequired2; _parameters.ItemAdditionalIsRequired3 = updateDto.ItemAdditionalIsRequired3; _parameters.ItemAdditionalIsRequired4 = updateDto.ItemAdditionalIsRequired4; _parameters.ItemAdditionalIsRequired5 = updateDto.ItemAdditionalIsRequired5; _parameters.ItemAdditionalIsRequired6 = updateDto.ItemAdditionalIsRequired6; _parameters.ItemAdditionalIsRequired7 = updateDto.ItemAdditionalIsRequired7; _parameters.ItemAdditionalIsRequired8 = updateDto.ItemAdditionalIsRequired8; _parameters.ItemAdditionalIsRequired9 = updateDto.ItemAdditionalIsRequired9; _parameters.ItemAdditionalIsRequired10 = updateDto.ItemAdditionalIsRequired10; //Acount Setting _parameters.PWTemplate = updateDto.PWTemplate; _parameters.PWChangeDays = updateDto.PWChangeDays; _parameters.InitailPWChangeRequied = updateDto.InitailPWChangeRequied; //this.CreateUpdateHistory(_parameters, CommonData.FunctionGr.SY_Parameters); //Save to database returnCode = context.Saves(); } else { returnCode = CommonData.DbReturnCode.DataNotFound; } } } catch (Exception ex) { returnCode = this.ProcessDbException(ex); } return(returnCode); }
protected void setModified(object ex) { BaseDao.instance().Entry(ex).State = System.Data.Entity.EntityState.Modified; }
public MonitorCmdBO(BaseDao <monitor_cmd> dao) : base(dao) { }
public AppPrivilegeBO(BaseDao <AppPrivilege> dao) : base(dao) { }
public UserInfoBO(BaseDao <UserInfo> dao) : base(dao) { }
public static IDao GetDao(string daoName) { IDao dao = new BaseDao(); switch (daoName) { case "DaoSysCmpInf": dao.SelectPrc = "P_SYS_Get_CmpInf"; break; case "DaoSysMenu": dao = new DaoSysMenu(); break; case "DaoSysUser": dao.SelectPrc = "P_Sys_Get_User"; dao.InsertPrc = "P_Sys_Oper_User"; dao.UpdatePrc = "P_Sys_Oper_User"; dao.DeletePrc = "P_Sys_Oper_User"; dao.PKField = "UserName"; break; case "DaoSysPrivilege": dao.SelectPrc = "P_Sys_Get_Privilege"; dao.InsertPrc = "P_Sys_Oper_Privilege"; break; case "DaoBasDept": dao.SelectPrc = "P_Bas_Get_Dept"; dao.InsertPrc = "P_Bas_Oper_Dept"; dao.UpdatePrc = "P_Bas_Oper_Dept"; dao.DeletePrc = "P_Bas_Oper_Dept"; dao.PKField = "Code"; break; case "DaoBasEmployee": dao.SelectPrc = "P_BAS_Get_Employee"; dao.InsertPrc = "P_Bas_Oper_Employee"; dao.UpdatePrc = "P_Bas_Oper_Employee"; dao.DeletePrc = "P_Bas_Oper_Employee"; dao.PKField = "Code"; break; case "DaoCommon": dao.SelectPrc = "P_COM_Get_Codes"; break; case "DaoBizFile": dao.SelectPrc = "P_Biz_Get_File"; dao.InsertPrc = "P_Biz_Oper_File"; dao.UpdatePrc = "P_Biz_Oper_File"; dao.DeletePrc = "P_Biz_Oper_File"; break; case "DaoBizContract": dao.SelectPrc = "P_Biz_Get_Contract"; dao.InsertPrc = "P_Biz_Oper_Contract"; dao.UpdatePrc = "P_Biz_Oper_Contract"; dao.DeletePrc = "P_Biz_Oper_Contract"; dao.PKField = "Code"; break; case "DaoBizFamily": dao.SelectPrc = "P_Biz_Get_Family"; dao.InsertPrc = "P_Biz_Oper_Family"; dao.UpdatePrc = "P_Biz_Oper_Family"; dao.DeletePrc = "P_Biz_Oper_Family"; dao.PKField = "ID"; break; case "DaoBizResume": dao.SelectPrc = "P_Biz_Get_Resume"; dao.InsertPrc = "P_Biz_Oper_Resume"; dao.UpdatePrc = "P_Biz_Oper_Resume"; dao.DeletePrc = "P_Biz_Oper_Resume"; dao.PKField = "ID"; break; case "DaoBizPerformance": dao.SelectPrc = "P_Biz_Get_Performance"; dao.InsertPrc = "P_Biz_Oper_Performance"; dao.UpdatePrc = "P_Biz_Oper_Performance"; dao.DeletePrc = "P_Biz_Oper_Performance"; dao.PKField = "ID"; break; case "DaoBizRwdAndPnh": dao.SelectPrc = "P_Biz_Get_RwdAndPnh"; dao.InsertPrc = "P_Biz_Oper_RwdAndPnh"; dao.UpdatePrc = "P_Biz_Oper_RwdAndPnh"; dao.DeletePrc = "P_Biz_Oper_RwdAndPnh"; dao.PKField = "ID"; break; case "DaoBizTraining": dao.SelectPrc = "P_Biz_Get_Training"; dao.InsertPrc = "P_Biz_Oper_Training"; dao.UpdatePrc = "P_Biz_Oper_Training"; dao.DeletePrc = "P_Biz_Oper_Training"; dao.PKField = "ID"; break; case "DaoBizTransfer": dao.SelectPrc = "P_Biz_Get_Transfer"; dao.InsertPrc = "P_Biz_Oper_Transfer"; dao.UpdatePrc = "P_Biz_Oper_Transfer"; dao.DeletePrc = "P_Biz_Oper_Transfer"; dao.PKField = "ID"; break; case "DaoBizLeave": dao.SelectPrc = "P_Biz_Get_Leave"; dao.InsertPrc = "P_Biz_Oper_Leave"; dao.UpdatePrc = "P_Biz_Oper_Leave"; dao.DeletePrc = "P_Biz_Oper_Leave"; dao.PKField = "ID"; break; case "RepDckEmpDate": dao.SelectPrc = "P_Rep_DckEmpDate"; break; } return(dao); }
public DeviceBO(BaseDao <Device> dao) : base(dao) { }
public BaseBO(string configName) { _dao = new CommonDao <T>(configName); }
public DeviceExceptionBo(BaseDao <DeviceException> dao) : base(dao) { }
public BaseService(DBEntity entity) { this.serviceModel = new BaseDao <T>(entity); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { YwAttach att = new YwAttach(); att.Dataid = Entity.Did; att.Type = "1"; BaseDao baseDao = new BaseDao(); IList <YwAttach> list = baseDao.List(att); if (list.Count > 0) { string pic = System.Configuration.ConfigurationManager.AppSettings["Pic"].Trim(); string[] picArr = pic.Split('|'); int index = 0; foreach (YwAttach temp in list) { index++; string title = "<hr/><h4>附件" + index + ":" + temp.RealName + "</h4>"; string[] arr = temp.FileN.Split('.'); string tailT = arr[arr.Length - 1].Trim().ToUpper(); string[] pathArr = temp.Dic.Split('\\'); string relPath = ""; bool enter = false; for (int i = 0; i < pathArr.Length; i++) { if (pathArr[i] == "") { continue; } if (pathArr[i] == "upload" || enter == true) { relPath += pathArr[i] + "\\"; enter = true; } } bool isPic = false; foreach (string picT in picArr) { if (tailT == picT) { Image img = new Image(); img.ImageUrl = relPath + temp.FileN; title += "<a href='" + relPath + temp.FileN + "'>下载</a><hr/>"; this.panCon.Controls.Add(new LiteralControl(title)); this.panCon.Controls.Add(img); isPic = true; break; } } if (isPic == true) { continue; } HyperLink link = new HyperLink(); link.NavigateUrl = relPath + temp.FileN; link.Text = temp.RealName; title += "<a href='" + relPath + temp.FileN + "'>下载</a><hr/>"; this.panCon.Controls.Add(new LiteralControl(title)); this.panCon.Controls.Add(link); } } else { Label lab = new Label(); lab.Text = "没有附件"; this.panCon.Controls.Add(lab); } } }
public BaseService(string EntitiesName) { this.serviceModel = new BaseDao <T>(EntitiesName); }
public MonitorDefindBO(BaseDao <Monitor_Defind> dao) : base(dao) { }
public MonitorLinkmanBO(BaseDao <Monitor_linkman> dao) : base(dao) { }
public int SelectSysAdditionalItem(out DataTable dtResult) { int returnCode = CommonData.DbReturnCode.Succeed; dtResult = new DataTable(); List <SYS_ParameterDto> lstResult = new List <SYS_ParameterDto>(); using (BaseDao context = new BaseDao()) { try { var par = context.sy_parameters.FirstOrDefault(); SYS_ParameterDto addItem1 = new SYS_ParameterDto { ItemAdditional1 = par.ItemAdditional1, ItemAdditional1EN = par.ItemAdditional1EN, ItemAdditional1JP = par.ItemAdditional1JP, ItemAdditionalIsActive1 = par.ItemAdditionalIsActive1, }; lstResult.Add(addItem1); SYS_ParameterDto addItem2 = new SYS_ParameterDto { ItemAdditional2 = par.ItemAdditional2, ItemAdditional2EN = par.ItemAdditional2EN, ItemAdditional2JP = par.ItemAdditional2JP, ItemAdditionalIsActive2 = par.ItemAdditionalIsActive2, }; lstResult.Add(addItem2); SYS_ParameterDto addItem3 = new SYS_ParameterDto { ItemAdditional3 = par.ItemAdditional3, ItemAdditional3EN = par.ItemAdditional3EN, ItemAdditional3JP = par.ItemAdditional3JP, ItemAdditionalIsActive3 = par.ItemAdditionalIsActive3, }; lstResult.Add(addItem3); SYS_ParameterDto addItem4 = new SYS_ParameterDto { ItemAdditional4 = par.ItemAdditional4, ItemAdditional4EN = par.ItemAdditional4EN, ItemAdditional4JP = par.ItemAdditional4JP, ItemAdditionalIsActive4 = par.ItemAdditionalIsActive4, }; lstResult.Add(addItem4); SYS_ParameterDto addItem5 = new SYS_ParameterDto { ItemAdditional5 = par.ItemAdditional5, ItemAdditional5EN = par.ItemAdditional5EN, ItemAdditional5JP = par.ItemAdditional5JP, ItemAdditionalIsActive5 = par.ItemAdditionalIsActive5, }; lstResult.Add(addItem5); SYS_ParameterDto addItem6 = new SYS_ParameterDto { ItemAdditional6 = par.ItemAdditional6, ItemAdditional6EN = par.ItemAdditional6EN, ItemAdditional6JP = par.ItemAdditional6JP, ItemAdditionalIsActive6 = par.ItemAdditionalIsActive6, }; lstResult.Add(addItem6); SYS_ParameterDto addItem7 = new SYS_ParameterDto { ItemAdditional7 = par.ItemAdditional7, ItemAdditional7EN = par.ItemAdditional7EN, ItemAdditional7JP = par.ItemAdditional7JP, ItemAdditionalIsActive7 = par.ItemAdditionalIsActive7, }; lstResult.Add(addItem7); SYS_ParameterDto addItem8 = new SYS_ParameterDto { ItemAdditional8 = par.ItemAdditional8, ItemAdditional8EN = par.ItemAdditional8EN, ItemAdditional8JP = par.ItemAdditional8JP, ItemAdditionalIsActive8 = par.ItemAdditionalIsActive8, }; lstResult.Add(addItem8); SYS_ParameterDto addItem9 = new SYS_ParameterDto { ItemAdditional9 = par.ItemAdditional9, ItemAdditional9EN = par.ItemAdditional9EN, ItemAdditional9JP = par.ItemAdditional9JP, ItemAdditionalIsActive9 = par.ItemAdditionalIsActive9, }; lstResult.Add(addItem9); SYS_ParameterDto addItem10 = new SYS_ParameterDto { ItemAdditional10 = par.ItemAdditional10, ItemAdditional10EN = par.ItemAdditional10EN, ItemAdditional10JP = par.ItemAdditional10JP, ItemAdditionalIsActive10 = par.ItemAdditionalIsActive10, }; lstResult.Add(addItem10); dtResult = ToDataTable(lstResult); } catch (Exception ex) { returnCode = ProcessDbException(ex); } } return(returnCode); }
/// <summary> /// 自動產生SELECT語法 /// </summary> /// <param name="obj">資料物件</param> /// <returns></returns> public static StringBuilder Query(object obj) { BaseDao objBaseDao = new BaseDao(); StringBuilder strSql = new StringBuilder(); string strTableName = string.Empty; StringBuilder strFieldName = new StringBuilder(); int index = 0; foreach (PropertyInfo objItem in obj.GetType().GetProperties()) { //將TABLE_NAME記錄至strTableName中 if (objItem.Name == "TABLE_NAME") { strTableName = objItem.GetValue(obj, null).ToString(); } else { if (index == 0) { strFieldName.AppendLine(objItem.Name + " "); } else { strFieldName.AppendLine(", " + objItem.Name + " "); } index = 1; } } strSql.AppendLine("SELECT "); strSql.AppendLine(strFieldName + " "); strSql.AppendLine("FROM " + strTableName + " "); strSql.AppendLine("WHERE 1=1 "); return strSql; }
/// <summary> /// 导出设备列表信息 /// </summary> /// <param name="status">设备状态</param> /// <param name="warrantyStatus">维保状态</param> /// <param name="departmentID">设备科室编号</param> /// <param name="filterTextName">设备名称</param> /// <param name="filterTextSerialCode">设备序列号</param> /// <param name="useStatus">设备使用状态</param> /// <param name="searchField">搜索字段</param> /// <param name="searchValue">搜索框填写内容</param> /// <param name="sortField">排序字段</param> /// <param name="sortDirection">排序方式</param> /// <returns>设备列表信息excel</returns> public ActionResult ExportEquipments(int status, int warrantyStatus, int departmentID, string filterTextName, string filterTextSerialCode, bool useStatus, string filterField, string filterText, string sortField, bool sortDirection, int fujiClass2ID = 0) { if (CheckSession() == false) { return(Json(ResultModelBase.CreateTimeoutModel(), JsonRequestBehavior.AllowGet)); } if (CheckSessionID() == false) { return(Json(ResultModelBase.CreateLogoutModel(), JsonRequestBehavior.AllowGet)); } ResultModelBase result = new ResultModelBase(); try { List <EquipmentInfo> equipments = null; BaseDao.ProcessFieldFilterValue(filterField, ref filterText); equipments = this.equipmentDao.QueryEquipments(status, warrantyStatus, departmentID, fujiClass2ID, filterTextName, filterTextSerialCode, useStatus, filterField, filterText, sortField, sortDirection); DataTable dt = new DataTable("Sheet1"); dt.Columns.Add("系统编号"); dt.Columns.Add("设备名称"); dt.Columns.Add("设备型号"); dt.Columns.Add("设备序列号"); dt.Columns.Add("厂商"); dt.Columns.Add("标准响应时间(分)"); dt.Columns.Add("等级"); dt.Columns.Add("设备类别 (I)"); dt.Columns.Add("设备类别 (II)"); dt.Columns.Add("设备类别 (III)"); dt.Columns.Add("分类编码"); dt.Columns.Add("整包范围"); dt.Columns.Add("品牌"); dt.Columns.Add("出厂日期"); dt.Columns.Add("备注"); dt.Columns.Add("富士I类"); dt.Columns.Add("富士II类"); dt.Columns.Add("固定资产"); dt.Columns.Add("资产等级"); dt.Columns.Add("注册证有效日期"); dt.Columns.Add("资产编号"); dt.Columns.Add("折旧年限(年)"); dt.Columns.Add("销售合同名称"); dt.Columns.Add("购入方式"); dt.Columns.Add("采购日期"); dt.Columns.Add("经销商"); dt.Columns.Add("采购金额(元)"); dt.Columns.Add("设备产地"); dt.Columns.Add("使用科室"); dt.Columns.Add("安装地点"); dt.Columns.Add("安装日期"); dt.Columns.Add("启用日期"); dt.Columns.Add("验收状态"); dt.Columns.Add("验收时间"); dt.Columns.Add("使用状态"); dt.Columns.Add("设备状态"); dt.Columns.Add("维保状态"); dt.Columns.Add("强检标记"); dt.Columns.Add("强检时间"); dt.Columns.Add("召回标记"); dt.Columns.Add("召回时间"); dt.Columns.Add("巡检周期"); dt.Columns.Add("保养周期"); dt.Columns.Add("校准周期"); foreach (EquipmentInfo equipment in equipments) { dt.Rows.Add(equipment.OID, equipment.Name, equipment.EquipmentCode, equipment.SerialCode, equipment.Manufacturer.Name, equipment.ResponseTimeLength, equipment.EquipmentLevel.Name, equipment.EquipmentClass1.Description, equipment.EquipmentClass2.Description, equipment.EquipmentClass3.Description, equipment.ClassCode, equipment.ServiceScope == true? "是":"否", equipment.Brand, equipment.ManufacturingDate == DateTime.MinValue ? "" : equipment.ManufacturingDate.ToString("yyyy-MM-dd"), equipment.Comments, equipment.FujiClass2.FujiClass1.Name, equipment.FujiClass2.Name, equipment.FixedAsset == true? "是":"否", equipment.AssetLevel.Name, equipment.ValidityStartDate == DateTime.MinValue ? "" : equipment.ValidityStartDate.ToString("yyyy-MM-dd") + " - " + equipment.ValidityEndDate.ToString("yyyy-MM-dd"), equipment.AssetCode, equipment.DepreciationYears, equipment.SaleContractName, equipment.PurchaseWay, equipment.PurchaseDate.ToString("yyyy-MM-dd"), equipment.Supplier.Name, equipment.PurchaseAmount, equipment.IsImport == true ? "进口" : "国产", equipment.Department.Name, equipment.InstalSite, equipment.InstalDate.ToString("yyyy-MM-dd"), equipment.UseageDate == DateTime.MinValue ? "" : equipment.UseageDate.ToString("yyyy-MM-dd"), equipment.Accepted == true ? "已验收" : "未验收", equipment.AcceptanceDate == DateTime.MinValue ? "" : equipment.AcceptanceDate.ToString("yyyy-MM-dd"), equipment.UsageStatus.Name, equipment.EquipmentStatus.Name, equipment.WarrantyStatus, equipment.MandatoryTestStatus.Name == "" ? "无" : equipment.MandatoryTestStatus.Name, equipment.MandatoryTestDate == DateTime.MinValue ? "" : equipment.MandatoryTestDate.ToString("yyyy-MM-dd"), equipment.RecallFlag == true ? "是" : "否", equipment.RecallDate == DateTime.MinValue ? "" : equipment.RecallDate.ToString("yyyy-MM-dd"), equipment.PatrolType.Name != "" ? equipment.PatrolPeriod + equipment.PatrolType.Name : "无巡检", equipment.MaintenanceType.Name != "" ? equipment.MaintenancePeriod + equipment.MaintenanceType.Name : "无保养", equipment.CorrectionType.Name != "" ? equipment.CorrectionPeriod + equipment.CorrectionType.Name : "无巡检" ); } MemoryStream ms = ExportUtil.ToExcel(dt); Response.AddHeader("Set-Cookie", "fileDownload=true; path=/"); return(File(ms, "application/excel", "设备列表.xlsx")); } catch (Exception ex) { NLog.LogManager.GetCurrentClassLogger().Error(ex, ex.Message); result.SetFailed(ResultCodes.SystemError, ControlManager.GetSettingInfo().ErrorMessage); } return(Json(result, JsonRequestBehavior.AllowGet)); }
//private static readonly Logger log = new Logger(); /// <summary> /// Search Data in sy_systemjournals table /// </summary> /// <param name="dtResult"> /// Out a Datatable that contains search result(all columns) in sy_systemjournals table /// </param> /// <returns> /// 0: Search successful /// others: Sql Exception /// </returns> public int SelectData(SYS_JournalDto dto, out DataTable dtResult) { int returnCode = 0; dtResult = new DataTable(); try { using (BaseDao context = new BaseDao()) { var query = context.sy_systemjournals.AsQueryable(); #region Search Condition //Filter by FunctionID if (!CommonMethod.IsNullOrEmpty(dto.FunctionID)) { query = query.Where(j => j.FunctionID.Equals(dto.FunctionID)); } //Filter by FromDate if (dto.FromDate != null) { dto.FromDate = new DateTime(dto.FromDate.Value.Year, dto.FromDate.Value.Month, dto.FromDate.Value.Day); query = query.Where(j => j.ActionDate >= dto.FromDate); } //Filter by ToDate if (dto.ToDate != null) { dto.ToDate = new DateTime(dto.ToDate.Value.Year, dto.ToDate.Value.Month, dto.ToDate.Value.Day); dto.ToDate = dto.ToDate.Value.Date.AddDays(1).AddSeconds(-1); query = query.Where(j => j.ActionDate <= dto.ToDate); } //Filter by EmployeeID if (!CommonMethod.IsNullOrEmpty(dto.EmployeeID)) { query = query.Where(j => j.EmployeeID.ToLower().Contains(dto.EmployeeID.ToLower())); } //Filter by EmployeeName if (!CommonMethod.IsNullOrEmpty(dto.EmployeeName)) { //query = query.Where(j => j.EmployeeName.ToLower().Contains(dto.EmployeeName.ToLower())); query = query.Where(j => j.UserName.ToLower().Contains(dto.EmployeeName.ToLower())); } //Filter by Action if (!CommonMethod.IsNullOrEmpty(dto.Action)) { query = query.Where(j => j.Action.Equals(dto.Action)); } #endregion Search Condition var result = from j in query orderby j.ID ascending select new SYS_JournalDto { ID = j.ID, FunctionID = j.FunctionID, UserCode = j.UserCode, UserName = j.UserName, ActionDate = j.ActionDate, Action = j.Action }; dtResult = ToDataTable(result); } } catch (Exception ex) { returnCode = this.ProcessDbException(ex); } return(returnCode); }
public BaseService() { baseDao = new BaseDao(); }
public ReportRepository() { _dao = new BaseDao(); }
public SMC_UserExceptionBo(BaseDao <SMC_UserException> dao) : base(dao) { }
public App4AIBO(BaseDao <App4AI> dao) : base(dao) { }
/// <summary> /// Update /// </summary> /// <param name="obj">資料物件</param> /// <param name="strFunctionName">Where條件的method name</param> /// <returns></returns> public static StringBuilder Update(object obj, string strFunctionName = "PK_") { BaseDao objBaseDao = new BaseDao(); StringBuilder strSql = new StringBuilder(); StringBuilder strParameter = new StringBuilder(); string strTableName = string.Empty; string strTag = "@"; List<string> liPrimaryKey = new List<string>(); //暫存PK值 int index = 0; string strDateString = "GETDATE()"; //取得物件的PK值 foreach (MethodInfo objMethod in obj.GetType().GetMethods()) { if (objMethod.Name.Substring(0, 3) == "PK_") { if (strFunctionName == "PK_") { strFunctionName = objMethod.Name; } foreach (ParameterInfo objParameter in objMethod.GetParameters()) { liPrimaryKey.Add(objParameter.Name); } } } //設定Update語法 foreach (PropertyInfo objItem in obj.GetType().GetProperties()) { //將TABLE_NAME記錄至strTableName中 if (objItem.Name == "TABLE_NAME") { strTableName = objItem.GetValue(obj, null).ToString(); } else { if (objItem.GetValue(obj, null) != null && objItem.Name != "TABLE_NAME") { if (index == 0) { if (objItem.GetValue(obj, null) != null && objItem.GetValue(obj, null).ToString() == strDateString) { strParameter.AppendLine(objItem.Name + "= " + strDateString + " "); } else { strParameter.AppendLine(objItem.Name + "= " + strTag + objItem.Name + " "); } } else { if (objItem.GetValue(obj, null) != null && objItem.GetValue(obj, null).ToString() == strDateString) { strParameter.AppendLine(", " + objItem.Name + " = " + strDateString + " "); } else { strParameter.AppendLine(", " + objItem.Name + " = " + strTag + objItem.Name + " "); } } index = 1; } } } strSql.AppendLine("UPDATE " + strTableName + " "); strSql.AppendLine("SET "); strSql.AppendLine(strParameter.ToString()); strSql.AppendLine("WHERE 1=1 "); //根據FunctionName的傳入參數組出Where條件 if (!string.IsNullOrEmpty(strFunctionName)) { //取得物件的Funtion foreach (MethodInfo objMethod in obj.GetType().GetMethods()) { if (objMethod.Name == strFunctionName) { foreach (ParameterInfo objParameter in objMethod.GetParameters()) { strSql.AppendLine(" AND " + objParameter.Name + " = " + strTag + objParameter.Name); } } } } return strSql; }
public MonitorLogBO(BaseDao <monitor_log> dao) : base(dao) { }
public StudentModuleRepository() { _dao = new BaseDao(); }
/// <summary> /// Insert /// </summary> /// <param name="obj">資料物件</param> /// <returns></returns> public static StringBuilder Insert(object obj) { BaseDao objBaseDao = new BaseDao(); StringBuilder strSql = new StringBuilder(); string strTableName = string.Empty; string strTag = "@"; StringBuilder strFieldName = new StringBuilder(); StringBuilder strParameter = new StringBuilder(); string strDateString = "GETDATE()"; int index = 0; foreach (PropertyInfo objItem in obj.GetType().GetProperties()) { //將TABLE_NAME記錄至strTableName中 if (objItem.Name == "TABLE_NAME") { strTableName = objItem.GetValue(obj, null).ToString(); } else { if (objItem.GetValue(obj, null) != null && objItem.Name != "TABLE_NAME") { if (index == 0) { if (objItem.GetValue(obj, null) != null && objItem.GetValue(obj, null).ToString() == strDateString) { strFieldName.AppendLine(objItem.Name + " "); strParameter.AppendLine(strDateString + " "); } else { strFieldName.AppendLine(objItem.Name + " "); strParameter.AppendLine(strTag + objItem.Name + " "); } } else { if (objItem.GetValue(obj, null) != null && objItem.GetValue(obj, null).ToString() == strDateString) { strFieldName.AppendLine(", " + objItem.Name + " "); strParameter.AppendLine(", " + strDateString + " "); } else { strFieldName.AppendLine(", " + objItem.Name + " "); strParameter.AppendLine(", " + strTag + objItem.Name + " "); } } index = 1; } } } strSql.AppendLine("INSERT INTO " + strTableName + " "); strSql.AppendLine("( "); strSql.AppendLine(strFieldName.ToString()); strSql.AppendLine(") "); strSql.AppendLine("VALUES "); strSql.AppendLine("( "); strSql.AppendLine(strParameter.ToString()); strSql.AppendLine(") "); return strSql; }
/// <summary> /// 自動發送公告 /// </summary> /// <param name="filter"></param> /// <returns></returns> public void SystemMessage(DataRow dr,DataTable dtSub) { Js.DAO.BaseDao dao = new BaseDao(FormID); dao.Add(dr); dao.SaveDetail(dtSub, ""); }
public TimetableRepository() { _dao = new BaseDao(); }