⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 itemcontentda0.cs.svn-base

📁 医院医德医风管理系统 B/S架构
💻 SVN-BASE
字号:
using System;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
/// <summary>
/// ExamineContentDA0 的摘要说明
/// </summary>
public class ItemContentDA0
{
	private static string constr = ConfigurationManager.ConnectionStrings["dahuaConnectionString"].ConnectionString;

    public ItemContentDA0()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
	}
    public static List<ItemContent> GetAllExamineContent(int itemId)
    {
        List<ItemContent> list = new List<ItemContent>();
        SqlConnection con = new SqlConnection(constr );
        con.Open();
        string sql = "Select * from ItemContent where ItemId=@ItemId Order By ItemContentOrder";
        SqlCommand command = new SqlCommand(sql, con);
        command.Parameters.Add(new SqlParameter("@ItemId",itemId));
        SqlDataReader reader = command.ExecuteReader();
        
        while (reader.Read())
        {
            ItemContent itemContent = new ItemContent();
            setItemContent(itemContent, reader);
            list.Add(itemContent);
        }
        if (list.Count == 0)
            list.Add(new ItemContent());
        return list;
    }

    private static void setItemContent(ItemContent itemContent, SqlDataReader reader)
    {
        itemContent.ItemId = (int)reader["ItemId"];
        itemContent.ItemContentId = (int)reader["ItemContentId"];
        itemContent.ItemContentOrder = (int)reader["ItemContentOrder"];
        itemContent.ItemContentName = reader["ItemContentName"].ToString();
        itemContent.ItemContentScore = (int)reader["ItemContentScore"];
    }

    public static List<ItemContent> GetAllItemContent()
    {
        using (SqlConnection con = new SqlConnection(constr))
        {
            List<ItemContent> list = new List<ItemContent>();

            con.Open();
            string sql = "Select * from ItemContent";
            SqlCommand command = new SqlCommand(sql, con);

            SqlDataReader reader = command.ExecuteReader();

            while (reader.Read())
            {
                ItemContent itemContent = new ItemContent();
                setItemContent(itemContent, reader);
                list.Add(itemContent);
            }
            con.Close();
            return list;
        }
    }
    public static bool AddExamineContent(ItemContent itemContent)
    {
        using (SqlConnection con = new SqlConnection(constr))
        {
            con.Open();

            string sql = "insert into ItemContent ( ItemId,ItemContentId,ItemContentOrder,ItemContentName,ItemContentScore) ";
            sql += "values (@ItemId,@ItemContentId,@ItemContentOrder,@ItemContentName,@ItemContentScore)";

            SqlCommand command = new SqlCommand(sql, con);
            command.Parameters.Add(new SqlParameter("@ItemId", itemContent.ItemId));
            command.Parameters.Add(new SqlParameter("@ItemContentId", itemContent.ItemContentId));
            command.Parameters.Add(new SqlParameter("@ItemContentOrder", itemContent.ItemContentOrder));
            command.Parameters.Add(new SqlParameter("@ItemContentName", itemContent.ItemContentName));
            command.Parameters.Add(new SqlParameter("@ItemContentScore", itemContent.ItemContentScore));

            try
            {
                command.ExecuteNonQuery();
                return true;
            }
            catch
            {
                return false;
            }
        }
        
    }
    public static bool UpdateExamineItem(ItemContent itemContent)
    {
        using (SqlConnection con = new SqlConnection(constr))
        {
        con.Open();
        string sql = "Update ItemContent  set  ItemContentName=@ItemContentName,ItemContentScore=@ItemContentScore,";
        sql += " ItemContentOrder=@ItemContentOrder, ItemId=@ItemId ";
        sql += " where ItemContentId=@ItemContentId";
        SqlCommand command = new SqlCommand(sql, con);
        command.Parameters.Add(new SqlParameter("@ItemId", itemContent.ItemId));
        command.Parameters.Add(new SqlParameter("@ItemContentId", itemContent.ItemContentId));
        command.Parameters.Add(new SqlParameter("@ItemContentOrder", itemContent.ItemContentOrder));
        command.Parameters.Add(new SqlParameter("@ItemContentName", itemContent.ItemContentName));
        command.Parameters.Add(new SqlParameter("@ItemContentScore", itemContent.ItemContentScore));
        try
        {
            command.ExecuteNonQuery();
            return true;
        }
        catch
        {
            return false;
        }
       
        }
        
    }
    public static bool DeleteExamineItem(ItemContent itemContent)
    {
       using (SqlConnection con = new SqlConnection(constr))
        {
        con.Open();
        string sql = "delete from ItemContent  where  ItemContentId=@ItemContentId";
      

        SqlCommand command = new SqlCommand(sql, con);
        command.Parameters.Add(new SqlParameter("@ItemContentId", itemContent.ItemContentId));
       
        
        try
        {
            command.ExecuteNonQuery();
            return true;
        }
        catch
        {
            return false;
        }
        
        }
    }
    
    
    
    public static int GetItemContentCountByItemId(int itemId)//获取考核内容总数
    {
        using (SqlConnection con = new SqlConnection(constr))
        {
            con.Open();
            string sql = "Select count(*) from ItemContent where ItemId=@ItemId";
            SqlCommand command = new SqlCommand(sql, con);
            command.Parameters.Add(new SqlParameter("@ItemId", itemId));
            int count = (int)command.ExecuteScalar();
             return count;
        }
    }
    public static bool InsertScore(Score score)
    {
        using (SqlConnection connection = new SqlConnection(constr))
        {
            connection.Open();
            string sql = "Insert into Score(PersonnelId,ItemId,ItemContentId,ScoreYear,ScoreMonth,Score) values(@PersonnelId,@ItemId,@ItemContentId,@ScoreYear,@ScoreMonth,@Socre)";
            SqlCommand command = new SqlCommand(sql, connection);
            command.Parameters.Add(new SqlParameter("@PersonnelId", score.PersonnelId));
            command.Parameters.Add(new SqlParameter("@ItemId", score.ItemId));
            command.Parameters.Add(new SqlParameter("@ItemContentId", score.ItemContentId));
            command.Parameters.Add(new SqlParameter("@ScoreYear", score.ScoreYear));
            command.Parameters.Add(new SqlParameter("@ScoreMonth", score.ScoreMonth));
            command.Parameters.Add(new SqlParameter("@Socre", score.Score1));
            int i = command.ExecuteNonQuery();
            if(i>0)
             return true;

            else 

            return false;
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -