📄 dataprocess.cs
字号:
using System;
using System.Data.OleDb;
using System.Collections.Generic;
using System.Text;
namespace myservice
{
class dataProcess
{
public static String getResult(String Query, String Segment, String conn_str)
{
OleDbConnection oledconn = new OleDbConnection(conn_str);
OleDbCommand cmd = new OleDbCommand(Query, oledconn);
try
{
oledconn.Open();
OleDbDataReader oled_reader = cmd.ExecuteReader();
if (oled_reader.Read())
{
return oled_reader[Segment].ToString();
}
return "";
}
catch (Exception ex)
{
throw (ex);
}
finally
{
oledconn.Close();
}
}
public static void Exec(String cmd_str, String conn_str)
{
OleDbConnection oledconn = new OleDbConnection(conn_str);
OleDbCommand cmd = new OleDbCommand(cmd_str, oledconn);
try
{
oledconn.Open();
cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw (ex);
}
finally
{
oledconn.Close();
}
}
public static int judge_time(String rsv_record_code, String term_start_time)
{
DateTime dt1 = Convert.ToDateTime(term_start_time);
int rrc = Int32.Parse(rsv_record_code);
int week = rrc / 1000;
int weekday = (rrc / 100) % 10;
int timespan = (week-1) * 7 + (weekday-1);
int time = (rrc / 10) % 10;
DateTime now = DateTime.Now;
TimeSpan tp = now.Subtract(dt1);
int time_now = 100;
if (now.Hour >= 10 && now.Hour < 12) time_now = 0;
if (now.Hour >= 14 && now.Hour < 16) time_now = 1;
if (now.Hour >= 16 && now.Hour < 18) time_now = 2;
if (now.Hour >= 18 && now.Hour < 22) time_now = 3;
if (timespan < tp.Days) return 0;
if (timespan==tp.Days&&time_now > time) return 0;
else return 1;
}
public static String getrsvcode(String term_start_time,String stu_id,String conn_str)
{
DateTime dt = Convert.ToDateTime(term_start_time);
DateTime now = DateTime.Now;
TimeSpan tp = now.Subtract(dt);
int time_segment = -10000;
int time_tmp=now.Hour*100+now.Minute;
if(time_tmp>=945 && time_tmp<1215)time_segment=0;
if(time_tmp>=1345 && time_tmp<1545)time_segment=1;
if(time_tmp>=1545 && time_tmp<1745)time_segment=2;
if(time_tmp>=1745 && time_tmp<2215)time_segment=3;
/*
if (now.Hour >= 10 && now.Hour < 12) time_segment = 0;
if (now.Hour >= 14 && now.Hour < 16) time_segment = 1;
if (now.Hour >= 16 && now.Hour < 18) time_segment = 2;
if (now.Hour >= 18 && now.Hour < 22) time_segment = 3;
*/
int week = tp.Days / 7+1;
int weekday = tp.Days % 7 + 1;
int record_code = week * 1000 + weekday * 100 + time_segment * 10;
return record_code.ToString();
}
public static String getRoom(int room_index, String conn_str)
{
String cmd_str = "select rsv_room from rsv_sets order by 编号";
OleDbConnection oledconn = new OleDbConnection(conn_str);
OleDbCommand cmd = new OleDbCommand(cmd_str, oledconn);
int count = 0;
try
{
oledconn.Open();
OleDbDataReader oled_reader = cmd.ExecuteReader();
while (oled_reader.Read())
{
if (room_index == count)
{
return oled_reader["rsv_room"].ToString();
}
count++;
}
return "0";
}
catch(Exception ex)
{
throw (ex);
}
finally
{
oledconn.Close();
}
}
public static int getCount(String Query, String conn_str)
{
OleDbConnection oledconn = new OleDbConnection(conn_str);
OleDbCommand cmd = new OleDbCommand(Query, oledconn);
try
{
oledconn.Open();
if (cmd.ExecuteScalar() != null)
{
return Int32.Parse(cmd.ExecuteScalar().ToString());
}
else
{
return 0;
}
}
catch (Exception ex)
{
throw (ex);
}
finally
{
oledconn.Close();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -