Exemplo n.º 1
0
        /*
         * 数据的导入
         */
        public static int excle(string url, string tb)
        {
            DataTable dt = DAL.DBHelper.getExcle(url);

            if (tb == "全校教师")
            {
                DataTable dtt = DAL.DBHelper.getDt("SELECT * FROM 教师 WHERE 工号='" + dt.Rows[5][1] + "'");
                if (dtt.Rows.Count == 0)
                {
                    for (int i = 1; i < dt.Rows.Count; i++)
                    {
                        dt.Rows[i][2] = PWDProcess.MD5Encrypt(dt.Rows[i][2].ToString(), PWDProcess.CreateKey(dt.Rows[i][1].ToString()));
                    }
                    DAL.DBHelper.SQLBulkCopy(dt, "教师");
                    DAL.DBHelper.getDt("DELETE FROM 教师 WHERE 部门='部门'");
                }
                else
                {
                    return(3);
                }
            }
            if (tb == "外聘教师")
            {
                DataTable dtt = DAL.DBHelper.getDt("SELECT * FROM 外聘教师 WHERE 工号='" + dt.Rows[5][1] + "'");
                if (dtt.Rows.Count == 0)
                {
                    DAL.DBHelper.waiteaSQLBulkCopy(dt, tb);
                    DAL.DBHelper.getDt("DELETE FROM 外聘教师 WHERE 部门='部门'");
                }
                if (dtt.Rows.Count != 0)
                {
                    return(3);
                }
                DataTable dtt1 = DAL.DBHelper.getDt("SELECT * FROM 教师 WHERE 工号='" + dt.Rows[5][1] + "'");
                if (dtt1.Rows.Count == 0)
                {
                    for (int i = 1; i < dt.Rows.Count; i++)
                    {
                        dt.Rows[i][2] = PWDProcess.MD5Encrypt(dt.Rows[i][2].ToString(), PWDProcess.CreateKey(dt.Rows[i][1].ToString()));
                    }
                    DAL.DBHelper.waipinTea(dt, "教师");
                    DAL.DBHelper.getDt("DELETE FROM 教师 WHERE 部门='部门'");
                }
                if (dtt1.Rows.Count != 0)
                {
                    return(3);
                }
            }
            if (tb == "信息艺术系" || tb == "会计系" || tb == "商务外语系" || tb == "食品工程系" || tb == "建筑工程系" || tb == "机械工程系" || tb == "经济管理系" || tb == "教务处" || tb == "基础教学部")
            {
                DAL.DBHelper.xibu(dt, "初始信息");
                DAL.DBHelper.getDt("DELETE FROM 初始信息 WHERE 承担单位='承担单位'");
            }
            return(1);
        }
Exemplo n.º 2
0
        /*
         * 修改教师密码
         */
        public static int updt(string pwd, string id, string ypwd)
        {
            string str = "UPDATE 教师 SET 密码='" + PWDProcess.MD5Encrypt(pwd.Trim(), PWDProcess.CreateKey(id.Trim())) + "' WHERE 工号='" + id.Trim() + "'";

            DAL.DBHelper.Getdt(str);
            DataTable dtt = DAL.DBHelper.getDt("SELECT 密码 FROM 教师 WHERE 工号='" + id.Trim() + "'");

            if (dtt.Rows[0][0].ToString() == PWDProcess.MD5Encrypt(pwd.Trim(), PWDProcess.CreateKey(id.Trim())))
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
Exemplo n.º 3
0
        /**
         * 新增教师用户
         *
         */
        public static int creatTeach(string YN, string dpm, string usrid, string userName, string sex, string Pwd, string permissions)
        {
            if (YN == "外聘教师")
            {
                string str = "INSERT INTO 教师(工号,密码,姓名,权限,性别,部门)VALUES('" + usrid + "','" + PWDProcess.MD5Encrypt(Pwd, PWDProcess.CreateKey(usrid)) + "','" + userName + "','" + permissions + "','" + sex + "','" + dpm + "')";
                DAL.DBHelper.Getdt(str);
                string str1 = "INSERT INTO 外聘教师(工号,密码,姓名,权限,性别,部门)VALUES('" + usrid + "','" + PWDProcess.MD5Encrypt(Pwd, PWDProcess.CreateKey(usrid)) + "','" + userName + "','" + permissions + "','" + sex + "','" + dpm + "')";
                DAL.DBHelper.Getdt(str1);
            }
            if (YN == "本校教师")
            {
                string str = "INSERT INTO 教师(工号,密码,姓名,权限,性别,部门)VALUES('" + usrid + "','" + PWDProcess.MD5Encrypt(Pwd, PWDProcess.CreateKey(usrid)) + "','" + userName + "','" + permissions + "','" + sex + "','" + dpm + "')";
                DAL.DBHelper.Getdt(str);
            }

            DataTable dt = DAL.DBHelper.getDt("SELECT * FROM 教师 WHERE 工号='" + usrid + "'");

            if (dt.Rows.Count == 1)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }