📄 operation.cs
字号:
con.Close();//关闭连接
return true;
}
catch
{
return false;
}
}
public bool InsertRecords(Records Re)
{
try
{
SqlConnection con = Operation.GetCon();
SqlCommand comm = new SqlCommand("AddRecord", con);
comm.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraRecordTitle = new SqlParameter("@RecordTitle", SqlDbType.VarChar, 50);//给存储过程添加参数
paraRecordTitle.Value = Re.RecordTitle;
comm.Parameters.Add(paraRecordTitle);
SqlParameter paraRecordDetails = new SqlParameter("@RecordDetails", SqlDbType.VarChar, 200);
paraRecordDetails.Value = Re.RecordDetails;
comm.Parameters.Add(paraRecordDetails);
SqlParameter paraUserName = new SqlParameter("@UserName", SqlDbType.VarChar, 20);
paraUserName.Value = Re.UserName;
comm.Parameters.Add(paraUserName);
SqlParameter paraAllot = new SqlParameter("@Allot", SqlDbType.VarChar, 50);
paraAllot.Value = Re.Allot;
comm.Parameters.Add(paraAllot);
SqlParameter paraCreateDate = new SqlParameter("@CreateDate", SqlDbType.DateTime, 8);
paraCreateDate.Value = Re.CreateDate;
comm.Parameters.Add(paraCreateDate);
con.Open();//打开数据库连接
comm.ExecuteNonQuery();//进行数据库操作
con.Close();//关闭连接
return true;
}
catch
{
return false;
}
}
public bool InsertResearchInfo(Research Re)
{
try
{
SqlConnection con = Operation.GetCon();
SqlCommand comm = new SqlCommand("InsResearchInfo", con);
comm.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraUserName = new SqlParameter("@UserName", SqlDbType.VarChar, 20);//给存储过程添加参数
paraUserName.Value = Re.UserName;//根据Re对象给存储过程的输入参数赋值
comm.Parameters.Add(paraUserName);
SqlParameter paraResearchDate = new SqlParameter("@ResearchDate", SqlDbType.DateTime, 8);
paraResearchDate.Value = Re.ResearchDate;
comm.Parameters.Add(paraResearchDate);
SqlParameter paraAppraise = new SqlParameter("@Appraise", SqlDbType.VarChar, 200);
paraAppraise.Value = Re.Appraise;
comm.Parameters.Add(paraAppraise);
SqlParameter paraReIdea = new SqlParameter("@ReIdea", SqlDbType.Int, 4);
paraReIdea.Value = Re.ReIdea;
comm.Parameters.Add(paraReIdea);
con.Open();//打开数据库连接
comm.ExecuteNonQuery();//进行数据库操作
con.Close();//关闭连接
return true;
}
catch
{
return false;
}
}
public DataSet Revert(string EngineerName)
{
SqlConnection con = Operation.GetCon();
SqlDataAdapter sda = new SqlDataAdapter("Revert", con);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraEngineerName = new SqlParameter("@EngineerName", SqlDbType.VarChar, 20);//给存储过程添加参数
paraEngineerName.Value = EngineerName;
sda.SelectCommand.Parameters.Add(paraEngineerName);//根据存储过程的输出参数的值对该方法的参数EngineerName赋值
con.Open(); //打开数据库连接
DataSet ds = new DataSet();
sda.Fill(ds);//进行数据库操作
con.Close();//关闭连接
return ds;
}
public bool BindRecords(int RecordID,Records Re)
{
try
{
SqlConnection con = Operation.GetCon();
SqlCommand comm = new SqlCommand("BindRecords", con);
comm.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraRecordID = new SqlParameter("@RecordID", SqlDbType.Int, 4);
paraRecordID.Value = RecordID;
comm.Parameters.Add(paraRecordID);
con.Open();//打开数据库连接
SqlDataReader dr = comm.ExecuteReader();//进行数据库操作
dr.Read();
Re.RecordID = (int)(dr["RecordID"]);
Re.RecordTitle = dr["RecordTitle"].ToString();
Re.RecordDetails = dr["RecordDetails"].ToString();
Re.EngineerName = dr["EngineerName"].ToString();
Re.UserName = dr["UserName"].ToString();
Re.CreateDate = (DateTime)(dr["CreateDate"]);
dr.Close();
con.Close();//关闭连接
return true;
}
catch
{
return false;
}
}
public bool InsertReRecordInfo( ReRecord myre)
{
try
{
SqlConnection con = Operation.GetCon();
SqlCommand comm = new SqlCommand("InsertReRecordInfo", con);
comm.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraRecordID = new SqlParameter("@RecordID", SqlDbType.Int, 4);//给存储过程添加参数
paraRecordID.Value = myre.RecordID;
comm.Parameters.Add(paraRecordID);
SqlParameter paraReReordContent = new SqlParameter("@ReReordContent", SqlDbType.VarChar, 200);
paraReReordContent.Value = myre.ReReordContent;
comm.Parameters.Add(paraReReordContent);
SqlParameter paraEngineerName = new SqlParameter("@EngineerName", SqlDbType.VarChar, 20);
paraEngineerName.Value = myre.EngineerName;
comm.Parameters.Add(paraEngineerName);
SqlParameter paraRevertDate = new SqlParameter("@RevertDate", SqlDbType.DateTime, 8);
paraRevertDate.Value = myre.RevertDate;
comm.Parameters.Add(paraRevertDate);
con.Open();//打开数据库连接
comm.ExecuteNonQuery();//进行数据库操作
con.Close();//关闭连接
return true;
}
catch
{
return false;
}
}
public int Judge(int RecordID)
{
SqlConnection con = Operation.GetCon();
SqlCommand comm = new SqlCommand("Judge", con);
comm.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraRecordID = new SqlParameter("@RecordID", SqlDbType.Int, 4);//给存储过程添加参数
paraRecordID.Value = RecordID;
comm.Parameters.Add(paraRecordID);
SqlParameter paraID = new SqlParameter("@ID", SqlDbType.Int, 4);
paraID.Direction = ParameterDirection.Output;//指出该参数是存储过程的Output参数
comm.Parameters.Add(paraID);
con.Open();//打开数据库连接
comm.ExecuteNonQuery();//进行数据库操作
con.Close();//关闭连接
int ID = (int)(paraID.Value);//根据存储过程的输出参数的值对该方法的参数ID赋值
return ID;
}
public bool UpdateReRecordInfo(int RecordID,string ReRecordContent,DateTime dt)
{
Operation oper = new Operation();
int ID = oper.Judge(RecordID);//根据Judge()返回的值对变量ID赋值
if (ID != 0)
{
SqlConnection con = Operation.GetCon();
SqlCommand comm = new SqlCommand("UpdateReRecordInfo", con);
comm.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraRecordID = new SqlParameter("@RecordID", SqlDbType.Int, 4);//给存储过程添加参数
paraRecordID.Value = RecordID;
comm.Parameters.Add(paraRecordID);
SqlParameter paraReRecordContent = new SqlParameter("@ReRecordContent", SqlDbType.VarChar, 200);
paraReRecordContent.Value = ReRecordContent;
comm.Parameters.Add(paraReRecordContent);
SqlParameter paraRevertDate = new SqlParameter("@RevertDate", SqlDbType.DateTime, 8);
paraRevertDate.Value=dt;
comm.Parameters.Add(paraRevertDate);
con.Open();//打开数据库连接
comm.ExecuteNonQuery();//进行数据库操作
con.Close();//关闭连接
return true;
}
else
{
return false;
}
}
public DataSet Search(string Search)
{
SqlConnection con = Operation.GetCon();
SqlDataAdapter sdr = new SqlDataAdapter("Find", con);
sdr.SelectCommand.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraSearch = new SqlParameter("@Search", SqlDbType.VarChar, 50);//给存储过程添加参数
paraSearch.Value = Search;
sdr.SelectCommand.Parameters.Add(paraSearch);
con.Open();//打开数据库连接
DataSet ds = new DataSet();
sdr.Fill(ds,"tb_Records");
con.Close();
return ds;
}
public bool count(Count cou)
{
try
{
SqlConnection con = Operation.GetCon();
SqlCommand comm = new SqlCommand("CountIdea", con);
comm.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraAll = new SqlParameter("@All", SqlDbType.Int, 4);
paraAll.Direction = ParameterDirection.Output;//指出该参数是存储过程的Output参数
comm.Parameters.Add(paraAll);
SqlParameter paraGood = new SqlParameter("@Good", SqlDbType.Int, 4);
paraGood.Direction = ParameterDirection.Output;//指出该参数是存储过程的Output参数
comm.Parameters.Add(paraGood);
SqlParameter paraBed = new SqlParameter("@Bad", SqlDbType.Int, 4);
paraBed.Direction = ParameterDirection.Output;//指出该参数是存储过程的Output参数
comm.Parameters.Add(paraBed);
SqlParameter paraCommon = new SqlParameter("@Common", SqlDbType.Int, 4);
paraCommon.Direction = ParameterDirection.Output;//指出该参数是存储过程的Output参数
comm.Parameters.Add(paraCommon);
con.Open();//打开数据库连接
comm.ExecuteNonQuery();//进行数据库操作
con.Close();//关闭连接
cou.All = (int)(paraAll.Value); //根据存储过程的输出参数的值 cou对象赋值
cou.Good = (int)(paraGood.Value);
cou.Bad = (int)(paraBed.Value);
cou.Common = (int)paraCommon.Value;
return true;
}
catch
{
return false;
}
}
public bool CheckUserName(string UserName)
{
//SqlConnection con = Operation.GetCon();
//SqlCommand comm = new SqlCommand("CheckUserName", con);
//comm.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
//SqlParameter paraUserName = new SqlParameter("@UserName", SqlDbType.VarChar, 20);//给存储过程添加参数
//paraUserName.Value = UserName;
//comm.Parameters.Add(paraUserName);
//con.Open();//打开数据库连接
//int count = Convert.ToInt32(comm.ExecuteScalar()); //进行数据库操作
//con.Close();//关闭连接
//if (count < 1)
//{
// return true;
//}
//else
//{
// return false;
//}
SqlConnection con = Operation.GetCon();
SqlDataAdapter sda = new SqlDataAdapter("CheckUserName", con);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraUserName = new SqlParameter("@UserName", SqlDbType.VarChar, 20);//给存储过程添加参数
paraUserName.Value = UserName;
sda.SelectCommand.Parameters.Add(paraUserName);
DataSet ds = new DataSet();
con.Open();//打开数据库连接
sda.Fill(ds);//执行数据库操作
con.Close();//关闭连接
if (ds.Tables[0].Rows.Count<1)
{
return true;
}
else
{
return false;
}
}
public DataSet myds(int ID)
{
SqlConnection con = Operation.GetCon();
SqlDataAdapter sda = new SqlDataAdapter("SelResearch", con);
sda.SelectCommand.CommandType = CommandType.StoredProcedure;//指明Sql命令的操作类型是使用存储过程
SqlParameter paraID = new SqlParameter("@ID", SqlDbType.Int, 4);
paraID.Value = ID;
sda.SelectCommand.Parameters.Add(paraID);
con.Open();
DataSet ds = new DataSet();
sda.Fill(ds);
con.Close();
return ds;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -