📄 viewservice.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Office.Model;
namespace Office.DAL
{
public static class ViewService
{
public static IList<ViewInfo> GetAllViewInfo()
{
String sql = "select * from View_Sign_Search";
return GetAllViewInfoBySql(sql);
}
public static IList<ViewInfo> GetViewInfoByCondition(String StartTime, String EndTime, String BranchName, String DepartName, String UserId, String UserName)
{
String sql = "select * from View_Sign_Search where 1=1";
if (StartTime != "" && EndTime != "" && StartTime != null && EndTime != null)
sql += " and SignTime between '" + StartTime + "' and '" + EndTime + "'";
if (BranchName != "" && BranchName != null)
sql += " and BranchName='" + BranchName + "'";
if (DepartName != "" && DepartName != null)
sql += " and DepartName='" + DepartName + "'";
if (UserId != "" && UserId != null)
sql += " and UserId='"+UserId+"'";
if (UserName != "" && UserName != null)
sql += " and UserName='"+UserName+"'";
return GetAllViewInfoBySql(sql);
}
public static IList<ViewInfo> GetViewInfoByCondition(String StartTime, String EndTime, String BranchName, String DepartName)
{
String sql = "select * from View_Sign_Search where 1=1";
if (StartTime != "" && EndTime != "" && StartTime != null && EndTime != null)
sql += " and SignTime between '" + StartTime + "' and '" + EndTime + "'";
if (BranchName != "" && BranchName != null)
sql += " and BranchName='" + BranchName + "'";
if (DepartName != "" && DepartName != null)
sql += " and DepartName='" + DepartName + "'";
return GetAllViewInfoBySql(sql);
}
private static IList<ViewInfo> GetAllViewInfoBySql(String safeSQL)
{
List<ViewInfo> list = new List<ViewInfo>();
try
{
SqlDataReader read = DBHelper.GetReader(safeSQL);
if (read.HasRows)
{
while (read.Read())
{
ViewInfo view = new ViewInfo();
view.UserId = read.GetString(0);
view.SignTime = read.GetDateTime(1).ToString();
view.SignDesc = read.GetString(2);
view.SignTag = read.GetInt32(3).ToString();
view.UserName = read.GetString(4);
view.BranchName = read.GetString(5);
view.DepartName = read.GetString(6);
list.Add(view);
}
}
read.Close();
return list;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
throw ex;
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -