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

📄 characterdao.cs.svn-base

📁 医院医德医风管理系统 B/S架构
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
            catch (Exception e) { }

            while (read.Read())
            {
                if (read["Positive1"] != DBNull.Value)
                    u.Positive = (int)read["Positive1"];
                else
                    u.Positive = 0;
                if (read["Positive2"] != DBNull.Value)
                    u.Positiveno = (int)read["Positive2"];
                else
                    u.Positiveno = 0;
                if (read["Red1"] != DBNull.Value)
                    u.Redresist = (int)read["Red1"];
                else
                    u.Redresist = 0;
                if (read["Red2"] != DBNull.Value)
                    u.Red = (int)read["Red2"];
                else
                    u.Red = 0;
                if (read["Recognition"] != DBNull.Value)
                    u.Recognition = (int)read["Recognition"];
                else
                    u.Recognition = 0;
                if (read["Flag"] != DBNull.Value)
                    u.Flag = (int)read["Flag"];
                else
                    u.Flag = 0;
                if (read["Tablet"] != DBNull.Value)
                    u.Tablet = (int)read["Tablet"];
                else
                    u.Tablet = 0;
                if (read["Other"] != DBNull.Value)
                    u.Other = (int)read["Other"];
                else
                    u.Other = 0;
                if (read["Complaint"] != DBNull.Value)
                    u.Complaint = (int)read["Complaint"];
                else
                    u.Complaint = 0;
                if (read["KouJiang"] != DBNull.Value)
                    u.KouJiang = (int)read["KouJiang"];
                else
                    u.Complaint = 0;
                if (read["Record1Sum"] != DBNull.Value)
                    u.Record1Sum = (int)read["Record1Sum"];
                else
                    u.Record1Sum = 0;
                if (read["Record5Sum"] != DBNull.Value)
                    u.Record5Sum = (int)read["Record5Sum"];
                else
                    u.Record5Sum = 0;
                if (read["Record7Sum"] != DBNull.Value)
                    u.Record7Sum = (int)read["Record7Sum"];
                else
                    u.Record7Sum = 0;
                if (unitname != null)
                    u.UnitName = unitname.ToString();
                if (personnelname != null)
                    u.PersonnelName = personnelname.ToString();
                u.UnitId = unitid;
                u.PersonnelId = personnelid;


            }

            con.Close();
        }
        return u;
    }
    public static bool AddCharacterAll(Character u, List<Personnel> listall)
    {
        List<Character> list = new List<Character>();
        using (SqlConnection con = new SqlConnection(constr))
        {
            con.Open();
            string sql = "SELECT PersonnelId,Unitid from Personnel";
            SqlCommand cmd = new SqlCommand(sql, con);
            cmd.Parameters.Add(new SqlParameter("@Ydate", u.Ydate));
            cmd.Parameters.Add(new SqlParameter("@Mdate", u.Ydate));
            SqlTransaction tran = con.BeginTransaction();
            cmd.Transaction = tran;
            SqlDataReader read0 = cmd.ExecuteReader();

            while (read0.Read())
            {
                Personnel p = new Personnel();
                p.PersonnelId = (int)read0["PersonnelId"];
                p.UnitId = (int)read0["UnitId"];
                bool exist = false;

                foreach (Personnel var in listall)
                {
                    if (var.PersonnelId == p.PersonnelId)
                    {
                        exist = true;
                        break;
                    }
                }

                if (!exist)
                {
                    u.PersonnelId = p.PersonnelId;
                    u.UnitId = p.UnitId;
                    if (p.PersonnelId != 0)
                        CharacterBL.AddCharacter(u);
                }


            }
            read0.Close();
            try
            {
                tran.Commit();
                return true;
            }
            catch (Exception e)
            {
                tran.Rollback();
                return false;
            }
            con.Close();

        }
    }
    public static bool AddCharacterKSAll(Character u, List<Unit> listall)
    {
        List<Character> list = new List<Character>();
        using (SqlConnection con = new SqlConnection(constr))
        {
            con.Open();
            string sql = "SELECT Unitid from Unit where Unitid!=0";
            SqlCommand cmd = new SqlCommand(sql, con);

            SqlTransaction tran = con.BeginTransaction();
            cmd.Transaction = tran;
            SqlDataReader read0 = cmd.ExecuteReader();

            while (read0.Read())
            {
                Unit p = new Unit();
                
                p.UnitId = (int)read0["UnitId"];
                bool exist = false;

                foreach (Unit var in listall)
                {
                    if (var.UnitId ==p.UnitId)
                    {
                        exist = true;
                        break;
                    }
                }

                if (!exist)
                {
                    u.PersonnelId = -1;
                    u.UnitId = p.UnitId;
                    if(u.UnitId !=0)
                    CharacterBL.AddCharacter(u);
                }


            }
            read0.Close();
            try
            {
                tran.Commit();
                return true;
            }
            catch (Exception e)
            {
                tran.Rollback();
                return false;
            }
            con.Close();

        }
    }
    public static List<Character> GetCharacterStateList(int Ydate1, int Mdate1, int Ydate2, int Mdate2, int unitid, int perid, string typeorder)
    {
        List<Character> list = new List<Character>();
        using (SqlConnection con = new SqlConnection(constr))
        {
            string sql = null;
            if (perid == -1)
            {
                sql += "select character.*,Unit.* from character,Unit where Character.CharacterUnitid=Unit.Unitid and Character.PersonnelId=@PersonnelID and Character.CharacterUnitId=@UnitID ";
            }
            else
            {
                sql = "select Character.*,Personnel.PersonnelName,Personnel.UnitId,Unit.UnitName from Character,Personnel,Unit where Personnel.PersonnelId=Character.PersonnelId and Unit.UnitId=Character.CharacterUnitId ";
            
                if (Ydate1 != 0 & Ydate2 != 0 & Mdate1 != 0 & Mdate2 != 0)
                    if (Ydate1 == Ydate2 & Mdate1 <= Mdate2)
                        sql += " and ydate=@ydate1 and mdate>=@Mdate1 and mdate<=@Mdate2";
                    else
                        sql += " and ((ydate>@ydate1 and ydate<@ydate2) or(ydate=@ydate1 and mdate>=@Mdate1) or(ydate=@ydate2 and mdate<=@Mdate2))";

                if (perid != 0)
                    sql += " and Character.PersonnelId=@PersonnelID";
                else
                {
                    if (unitid != 0)
                        sql += " and Character.CharacterUnitId=@UnitID";
                }
             }
            if (typeorder == "Record1Sum")
                sql += " and Record1Sum>0";

            if (typeorder == "Record5Sum")
                sql += " and Record5Sum>0";

            if (typeorder == "Record7Sum")
                sql += " and Record7Sum>0";

            if (typeorder == "Positiveno")
                sql += " and Positiveno>0";

            if (typeorder == "Redresist")
                sql += " and Redresist>0";

            if (typeorder == "Red")
                sql += " and Red>0";

            if (typeorder == "Recognition")
                sql += " and Recognition>0";

            if (typeorder == "Flag")
                sql += " and Flag>0";

            if (typeorder == "Tablet")
                sql += " and Tablet>0";

            if (typeorder == "Other")
                sql += " and Other>0";

            if (typeorder == "Complaint")
                sql += " and Complaint>0";

            if (typeorder == "KouJiang")
                sql += " and KouJiang>0";

            SqlCommand cmd = new SqlCommand(sql, con);
            if (Ydate1 != 0 & Ydate2 != 0)
            {
                cmd.Parameters.Add(new SqlParameter("@ydate1", Ydate1));
                cmd.Parameters.Add(new SqlParameter("@Mdate1", Mdate1));
                cmd.Parameters.Add(new SqlParameter("@ydate2", Ydate2));
                cmd.Parameters.Add(new SqlParameter("@Mdate2", Mdate2));
            }
            if (unitid != 0)
                cmd.Parameters.Add(new SqlParameter("@UnitID", unitid));
            if (perid != 0)
                cmd.Parameters.Add(new SqlParameter("@PersonnelID", perid));

            con.Open();
            SqlDataReader read = null;
            try
            {
                read = cmd.ExecuteReader();

            }
            catch (Exception e)
            {

            }

⌨️ 快捷键说明

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