Esempio n. 1
0
 /// <summary>
 /// 关键词查询
 /// </summary>
 /// <param name="key">关键词</param>
 /// <param name="part">是否取部分内容(加快查询和传输速度)</param>
 /// <param name="pos">起始位置</param>
 /// <param name="length">记录条数</param>
 /// <returns></returns>
 public static DataSet QueryGoodsKey(string key, bool part = false, int pos = 0, int length = 0)
 {
     try
     {
         if (part)
         {
             string           sql  = "select * from tb_goods where goodsName like ?key limit ?st, ?ed;";
             MySqlParameter[] para = new MySqlParameter[3];
             para[0] = new MySqlParameter("?key", "%" + key + "%");
             para[1] = new MySqlParameter("?st", pos);
             para[2] = new MySqlParameter("?ed", length);
             DataSet ds = DAL_MysqlHelper.ExecuteDataSet(sql, para);
             return(ds);
         }
         else
         {
             string         sql  = "select * from tb_goods where goodsName like ?key;";
             MySqlParameter para = new MySqlParameter("?key", "%" + key + "%");
             DataSet        ds   = DAL_MysqlHelper.ExecuteDataSet(sql, para);
             return(ds);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// 添加订单
        /// </summary>
        /// <param name="name"></param>
        /// <param name="goods"></param>
        /// <param name="gcnt"></param>
        /// <returns></returns>
        public static bool AddOrder(string name, List <Goods> goods, List <int> gcnt)
        {
            try
            {
                if (goods.Count != gcnt.Count)
                {
                    return(false);
                }
                decimal totalPrice = 0.0M;
                for (int i = 0; i < goods.Count; i++)
                {
                    totalPrice += goods.ElementAt(i).UnitPrice *gcnt.ElementAt(i);
                }

                string           sql  = "insert into tb_order(customerName,totalMoney,orderDate) values(?name,?money,now());";
                MySqlParameter[] para = { new MySqlParameter("?name", name), new MySqlParameter("?money", totalPrice) };
                int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
                if (ret == 1)
                {
                    return(AddOrderDetail(name, goods, gcnt));
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 3
0
 /// <summary>
 /// 添加一个学生用户。
 /// </summary>
 /// <param name="student">学生实体信息</param>
 /// <returns></returns>
 public static bool insertStudent(Student student)
 {
     try
     {
         string           sql  = "insert into users(username, password, sex, grade, age, major, IP, regtime) values(?0,?1,?2,?3,?4,?5,?6,?7);";
         MySqlParameter[] para = new MySqlParameter[8];
         para[0] = new MySqlParameter("?0", student.username);
         para[1] = new MySqlParameter("?1", student.password);
         para[2] = new MySqlParameter("?2", student.sex);
         para[3] = new MySqlParameter("?3", student.grade);
         para[4] = new MySqlParameter("?4", student.age);
         para[5] = new MySqlParameter("?5", student.major);
         para[6] = new MySqlParameter("?6", student.IP);
         para[7] = new MySqlParameter("?7", student.regtime);
         int res = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
         if (res > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         LogWriter.writeLine(@"C:\WEB_ASP\logs\DAL.log", "insertStudent:" + e.Message);
         return(false);
     }
 }
Esempio n. 4
0
 /// <summary>
 /// 查询某级类别的所有类别
 /// </summary>
 /// <param name="level">类别等级(1,2,3)</param>
 /// <returns></returns>
 public static List <GoodsType> QueryAlltypes(int level)
 {
     try
     {
         string tb_name = "tb_goodstype";
         if (level == 2)
         {
             tb_name += "_second";
         }
         else if (level == 3)
         {
             tb_name += "_third";
         }
         string           sql  = "select * from " + tb_name + ";";
         DataTable        dt   = DAL_MysqlHelper.ExecuteDataSet(sql).Tables[0];
         List <GoodsType> list = new List <GoodsType>();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             GoodsType type = new GoodsType();
             type.TypeID    = dt.Rows[i]["goodsTypeID"].ToString();
             type.TypeLevel = level;
             type.TypeName  = dt.Rows[i]["goodsTypeName"].ToString();
             if (level != 1)
             {
                 type.ParentTypeID = dt.Rows[i]["goodsParentTypeID"].ToString();
             }
             list.Add(type);
         }
         return(list);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 5
0
 /// <summary>
 /// 查询某类别从pos开始length条商品记录
 /// </summary>
 /// <param name="typeID"></param>
 /// <param name="pos"></param>
 /// <param name="length"></param>
 /// <returns></returns>
 public static List <Goods> QueryGoods(string typeID, int pos, int length)
 {
     try
     {
         string           sql  = "select * from tb_goods where goodsTypeID=?typeID limit ?st,?ed;";
         MySqlParameter[] para = new MySqlParameter[3];
         para[0] = new MySqlParameter("?typeID", typeID);
         para[1] = new MySqlParameter("?st", pos);
         para[2] = new MySqlParameter("?ed", length);
         List <Entitys.Goods> list = new List <Goods>();
         DataSet ds = DAL_MysqlHelper.ExecuteDataSet(sql, para);
         for (int i = 0; i < length; i++)
         {
             Entitys.Goods good = new Goods();
             good.Id        = ds.Tables[0].Rows[i][0].ToString();
             good.Name      = ds.Tables[0].Rows[i][1].ToString();
             good.TypeID    = ds.Tables[0].Rows[i][2].ToString();
             good.Desctipt  = ds.Tables[0].Rows[i][3].ToString();
             good.UnitPrice = decimal.Parse(ds.Tables[0].Rows[i][4].ToString());
             good.ImageName = ds.Tables[0].Rows[i][5].ToString();
             good.SellCount = ds.Tables[0].Rows[i][6].ToString();
             good.Date      = ds.Tables[0].Rows[i][7].ToString();
             list.Add(good);
         }
         return(list);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 6
0
        public static bool joinTeam(string teamID, string stuID, bool update = false)
        {
            string AuditMode = queryTeamAuditMode(teamID);
            string status    = AuditMode == "自动审核" ? "已加入" : "待审核";
            string sql       = "";

            MySqlParameter[] para = new MySqlParameter[2];
            try
            {
                if (!update)
                {
                    sql = "insert into team_member values(?0,?1,'" + status + "')";
                }
                else
                {
                    sql = "update team_member set AuditStatus='" + status + "' where TeamID=?0 and StuID=?1";
                }
                para[0] = new MySqlParameter("?0", teamID);
                para[1] = new MySqlParameter("?1", stuID);
                int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
                if (ret >= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 7
0
 /// <summary>
 /// 修改二/三级类别的父类
 /// </summary>
 /// <param name="level">类别等级(2,3)</param>
 /// <param name="typeID">TypeID</param>
 /// <param name="parentTypeID">ParentTypeID</param>
 /// <returns>bool</returns>
 public static bool UpdateParentTypeID(int level, string typeID, string parentTypeID)
 {
     try
     {
         string tb_name = "tb_goodstype";
         if (level == 2)
         {
             tb_name += "_second";
         }
         else if (level == 3)
         {
             tb_name += "_third";
         }
         string           sql  = "update " + tb_name + " set goodsParentTypeID=?parentTypeID where goodsTypeID=?typeID;";
         MySqlParameter[] para = new MySqlParameter[2];
         para[0] = new MySqlParameter("?parentTypeID", parentTypeID);
         para[1] = new MySqlParameter("?typeID", typeID);
         int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
         if (ret == 1)
         {
             return(true);
         }
         return(false);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 8
0
 /// <summary>
 /// 更新个人信息
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="birthday">Birthday</param>
 /// <param name="phone">Phone</param>
 /// <param name="email">Email</param>
 /// <returns>bool</returns>
 public static bool UpdatePersonalInfo(string name, string birthday, string phone, string email)
 {
     try
     {
         string sql = "update tb_customer set " + (birthday == ""?"": "customerBirthday=?birthday,") + "customerPhone=?phone,customerEmail=?email where customerName=?name;";
         List <MySqlParameter> paras = new List <MySqlParameter>();
         if (birthday != "")
         {
             paras.Add(new MySqlParameter("?birthday", birthday));
         }
         paras.Add(new MySqlParameter("?phone", phone));
         paras.Add(new MySqlParameter("?email", email));
         paras.Add(new MySqlParameter("?name", name));
         int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, paras.ToArray());
         if (ret == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 9
0
 /// <summary>
 /// 添加订单详细信息
 /// </summary>
 /// <param name="name"></param>
 /// <param name="goods"></param>
 /// <param name="gcnt"></param>
 /// <returns></returns>
 public static bool AddOrderDetail(string name, List <Goods> goods, List <int> gcnt)
 {
     try
     {
         string                  sql   = "select orderID from tb_order where customerName=?name order by orderDate limit 0,1;";
         MySqlParameter          para  = new MySqlParameter("?name", name);
         string                  id    = DAL_MysqlHelper.ExecuteDataSet(sql, para).Tables[0].Rows[0][0].ToString();
         List <string>           sqls  = new List <string>();
         List <MySqlParameter[]> paras = new List <MySqlParameter[]>();
         for (int i = 0; i < goods.Count; i++)
         {
             var              _goods = goods.ElementAt(i);
             string           _sql   = "insert into tb_orderdetail values(?orderID,?goodsID,?count);";
             MySqlParameter[] _para  = { new MySqlParameter("?orderID", id), new MySqlParameter("?goodsID", _goods.Id), new MySqlParameter("?count", gcnt.ElementAt(i)) };
             sqls.Add(_sql);
             paras.Add(_para);
         }
         bool ret = DAL_MysqlHelper.ExecuteNoQueryTran(sqls, paras);
         return(ret);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 10
0
 /// <summary>
 /// 添加用户
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="pass">Pass</param>
 /// <param name="question">Question</param>
 /// <param name="answer">Answer</param>
 /// <returns>bool</returns>
 public static bool AddCustomer(string name, string pass, string question, string answer)
 {
     try
     {
         string           sql  = "insert into tb_customer(customerName,customerPass,customerRegDate,customerQuestion,customerAnswer) values(?name,?pass,now(),?question,?answer);";
         MySqlParameter[] para = new MySqlParameter[4];
         para[0] = new MySqlParameter("?name", name);
         para[1] = new MySqlParameter("?pass", DAL_Safety.GetMD5(pass));
         para[2] = new MySqlParameter("?question", question);
         para[3] = new MySqlParameter("?answer", DAL_Safety.EncodeBase64(answer));
         int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
         if (ret == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 11
0
 /// <summary>
 /// 根据学号查询学生。
 /// </summary>
 /// <param name="number">要查询的学生学号</param>
 /// <returns>除密码、IP、注册时间外的所有学生信息</returns>
 public static Student queryStudent(string number)
 {
     try
     {
         string           sql  = "select username,sex,grade,age,major from users where username=?1;";
         MySqlParameter[] para = new MySqlParameter[1];
         para[0] = new MySqlParameter("?1", number);
         DataTable dataTable = DAL_MysqlHelper.ExecuteDataTable(sql, para).Tables[0];
         Student   student   = new Student("", "", "", "", "", "", "", "");
         if (dataTable != null)
         {
             student.username = dataTable.Rows[0]["username"].ToString();
             student.sex      = dataTable.Rows[0]["sex"].ToString();
             student.age      = dataTable.Rows[0]["age"].ToString();
             student.grade    = dataTable.Rows[0]["grade"].ToString();
             student.major    = dataTable.Rows[0]["major"].ToString();
         }
         return(student);
     }
     catch (Exception e)
     {
         LogWriter.writeLine(@"C:\WEB_ASP\logs\DAL.log", "queryStudent:" + e.Message);
         return(null);
     }
 }
Esempio n. 12
0
 /// <summary>
 /// 更新收货信息
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="trueName">TrueName</param>
 /// <param name="address">Address</param>
 /// <param name="postCode">PostCode</param>
 /// <returns>bool</returns>
 public static bool UpdatePostInfo(string name, string trueName, string address, string postCode)
 {
     try
     {
         string           sql  = "update tb_customer set customerTrueName=?trueName,customerAddress=?address,customerPostCode=?postCode where customerName=?name;";
         MySqlParameter[] para = new MySqlParameter[4];
         para[0] = new MySqlParameter("?trueName", trueName);
         para[1] = new MySqlParameter("?address", address);
         para[2] = new MySqlParameter("?postCode", postCode);
         para[3] = new MySqlParameter("?name", name);
         int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
         if (ret == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 13
0
        public static bool quitTeam(string teamID, string stuID)
        {
            string AuditMode = queryTeamAuditMode(teamID);
            string sql       = "";

            MySqlParameter[] para = new MySqlParameter[2];
            try
            {
                sql     = "update team_member set AuditStatus='未加入' where TeamID=?0 and StuID=?1";
                para[0] = new MySqlParameter("?0", teamID);
                para[1] = new MySqlParameter("?1", stuID);
                int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
                if (ret >= 1)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch
            {
                return(false);
            }
        }
Esempio n. 14
0
 public static bool modifyTeam(Team team)
 {
     try
     {
         string           sql  = "update team set AuditMode=?0,ScoreType=?1,AnswerStatus=?3,CourceName=?4,CourceTerm=?5,StuClass=?6,ScoreType=?7,Introduce=?8 where TeamID=?9";
         MySqlParameter[] para = new MySqlParameter[9];
         para[0] = new MySqlParameter("?0", team.AuditMode);
         para[1] = new MySqlParameter("?1", team.ScoreType);
         para[2] = new MySqlParameter("?3", team.AnswerStatus);
         para[3] = new MySqlParameter("?4", team.CourceName);
         para[4] = new MySqlParameter("?5", team.CourceTerm);
         para[5] = new MySqlParameter("?6", team.StuClass);
         para[6] = new MySqlParameter("?7", team.ScoreType);
         para[7] = new MySqlParameter("?8", team.Introduce);
         para[8] = new MySqlParameter("?9", team.TeamID);
         int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
         if (ret >= 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch
     {
         return(false);
     }
 }
Esempio n. 15
0
 /// <summary>
 /// 添加一个商品
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="typeID">TypeID</param>
 /// <param name="unitPrice">UnitPrice</param>
 /// <param name="descript">Descript</param>
 /// <param name="imageName">ImageName</param>
 /// <returns>bool</returns>
 public static bool AddGood(string name, string typeID, decimal unitPrice, string descript = "", string imageName = "")
 {
     try
     {
         string           sql  = "insert into tb_goods(goodsName,goodsTypeID,goodsUnitPrice,goodsDescript,goodsImageName,goodsDate) values(?name,?typeID,?unitPrice,?descript,?imageName,now());";
         MySqlParameter[] para = new MySqlParameter[5];
         para[0] = new MySqlParameter("?name", name);
         para[1] = new MySqlParameter("?typeID", typeID);
         para[2] = new MySqlParameter("?unitPrice", unitPrice);
         para[3] = new MySqlParameter("?descript", descript);
         para[4] = new MySqlParameter("?imageName", imageName);
         int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
         if (ret == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 16
0
 /// <summary>
 /// 根据TypeID查询某级类别详细信息
 /// </summary>
 /// <param name="level">类别等级(1,2,3)</param>
 /// <param name="typeID">TypeID</param>
 /// <returns>GoodsType</returns>
 public static GoodsType QueryTypeName(int level, string typeID)
 {
     try
     {
         string tb_name = "tb_goodstype";
         if (level == 2)
         {
             tb_name += "_second";
         }
         else if (level == 3)
         {
             tb_name += "_third";
         }
         string         sql  = "select * from " + tb_name + " where goodsTypeID=?typeID;";
         MySqlParameter para = new MySqlParameter("?typeID", typeID);
         DataTable      dt   = DAL_MysqlHelper.ExecuteDataSet(sql, para).Tables[0];
         GoodsType      type = new GoodsType();
         type.TypeID    = typeID;
         type.TypeLevel = level;
         type.TypeName  = dt.Rows[0]["goodsTypeName"].ToString();
         if (level != 1)
         {
             type.ParentTypeID = dt.Rows[0]["goodsParentTypeID"].ToString();
         }
         return(type);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 17
0
 /// <summary>
 /// 更新商品信息
 /// </summary>
 /// <param name="goods"></param>
 /// <returns></returns>
 public static bool UpdateGood(Goods goods)
 {
     try
     {
         string           sql  = "update tb_goods set goodsName=?name,goodsTypeID=?typeID,goodsDescript=?descript,goodsUnitPrice=?unitPrice,goodsImageName=?imageName where goodsID=?id;";
         MySqlParameter[] para = new MySqlParameter[6];
         para[0] = new MySqlParameter("?name", goods.Name);
         para[1] = new MySqlParameter("?typeID", goods.TypeID);
         para[2] = new MySqlParameter("?descript", goods.Desctipt);
         para[3] = new MySqlParameter("?unitPrice", goods.UnitPrice);
         para[4] = new MySqlParameter("?imageName", goods.ImageName);
         para[5] = new MySqlParameter("?id", goods.Id);
         int ret = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
         if (ret == 1)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 18
0
 /// <summary>
 /// 查询某级类别的所有子类
 /// </summary>
 /// <param name="level">类别等级(1,2)</param>
 /// <param name="typeID">TypeID</param>
 /// <returns>List<GoodsType></returns>
 public static List <GoodsType> QueryTypesChild(int level, string typeID)
 {
     try
     {
         level++;
         string tb_name = "tb_goodstype";
         if (level == 2)
         {
             tb_name += "_second";
         }
         else if (level == 3)
         {
             tb_name += "_third";
         }
         string           sql  = "select * from " + tb_name + " where goodsParentTypeID=?typeID;";
         MySqlParameter   para = new MySqlParameter("?typeID", typeID);
         DataTable        dt   = DAL_MysqlHelper.ExecuteDataSet(sql, para).Tables[0];
         List <GoodsType> list = new List <GoodsType>();
         for (int i = 0; i < dt.Rows.Count; i++)
         {
             GoodsType type = new GoodsType();
             type.TypeID    = dt.Rows[i]["goodsTypeID"].ToString();
             type.TypeLevel = level;
             type.TypeName  = dt.Rows[i]["goodsTypeName"].ToString();
             list.Add(type);
         }
         return(list);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 19
0
 /// <summary>
 /// 添加一个教师用户。
 /// </summary>
 /// <param name="teacher">教师实体信息</param>
 /// <returns></returns>
 public static bool insertTeacher(Teacher teacher)
 {
     try
     {
         string           sql  = "insert into teacher(username, password, sex, age) values(?0,?1,?2,?3);";
         MySqlParameter[] para = new MySqlParameter[4];
         para[0] = new MySqlParameter("?0", teacher.username);
         para[1] = new MySqlParameter("?1", teacher.password);
         para[2] = new MySqlParameter("?2", teacher.sex);
         para[3] = new MySqlParameter("?3", teacher.age);
         int res = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
         if (res > 0)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception e)
     {
         LogWriter.writeLine(@"C:\WEB_ASP\logs\DAL.log", "insertTeacher:" + e.Message);
         return(false);
     }
 }
Esempio n. 20
0
        /// <summary>
        /// 判断教师用户是否存在。
        /// </summary>
        /// <param name="number">用户名</param>
        /// <param name="password">密码</param>
        /// <returns></returns>
        public static bool teacherExits(string number, string password)
        {
            password = DAL_Safety.getMD5(password);
            object obj = null;

            try
            {
                string           sql  = "select username from teacher where username=?1 and password=?2;";
                MySqlParameter[] para = new MySqlParameter[2];
                para[0] = new MySqlParameter("?1", number);
                para[1] = new MySqlParameter("?2", password);
                obj     = DAL_MysqlHelper.ExecuteScalar(sql, para);
            }
            catch (Exception e)
            {
                LogWriter.writeLine(@"C:\WEB_ASP\logs\DAL.log", "studentExits:" + e.Message);
                return(false);
            }
            if (Equals(obj, null))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Esempio n. 21
0
        /// <summary>
        /// 修改一个学生信息(包括密码、年龄、年纪、性别、专业)。
        /// </summary>
        /// <param name="student">修改后的学生信息</param>
        /// <returns></returns>
        public static bool modifyStudent(Student student)
        {
            string username = student.username;
            string password = student.password;

            if (password.Length != 0)
            {
                password = DAL_Safety.getMD5(password);
            }
            string age   = student.age;
            string grade = student.grade;
            string sex   = student.sex;
            string major = student.major;

            try
            {
                string sql = "";
                int    res = 0;
                if (password.Length != 0)
                {
                    sql = "update users set password=?1, grade=?2, age=?3, sex=?4, major=?5 where username=?6;";
                    MySqlParameter[] para = new MySqlParameter[6];
                    para[0] = new MySqlParameter("?1", password);
                    para[1] = new MySqlParameter("?2", grade);
                    para[2] = new MySqlParameter("?3", age);
                    para[3] = new MySqlParameter("?4", sex);
                    para[4] = new MySqlParameter("?5", major);
                    para[5] = new MySqlParameter("?6", username);
                    res     = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
                }
                else
                {
                    sql = "update users set grade=?1, age=?2, sex=?3, major=?4 where username=?5;";
                    MySqlParameter[] para = new MySqlParameter[5];
                    para[0] = new MySqlParameter("?1", grade);
                    para[1] = new MySqlParameter("?2", age);
                    para[2] = new MySqlParameter("?3", sex);
                    para[3] = new MySqlParameter("?4", major);
                    para[4] = new MySqlParameter("?5", username);
                    res     = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
                }
                if (res > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                LogWriter.writeLine("DAL.log", "modifyStudent:" + e.Message);
                return(false);
            }
        }
Esempio n. 22
0
 /// <summary>
 /// 查询所有用户收货信息与个人信息(管理功能)
 /// </summary>
 /// <returns>DataSet 或 null</returns>
 public static DataSet QueryAllCustomer()
 {
     try
     {
         string  sql = "select customerName,customerTrueName,customerAddress,customerPostCode,customerBirthday,customerPhone,customerEmail from tb_customer;";
         DataSet ds  = DAL_MysqlHelper.ExecuteDataSet(sql);
         return(ds);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 23
0
 /// <summary>
 /// 查询商品总数
 /// </summary>
 /// <returns></returns>
 public static int QueryGoodsCount()
 {
     try
     {
         string sql = "select count(*) from tb_goods;";
         int    ret = Int32.Parse(DAL_MysqlHelper.ExecuteScalar(sql).ToString());
         return(ret);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 24
0
        /// <summary>
        /// 查询所有学生信息。
        /// </summary>
        /// <returns>DataSet</returns>
        public static DataSet queryAllStudent()
        {
            DataSet ds = null;

            try
            {
                string sql = "select username,sex,grade,age,major,IP,regtime,id from users;";
                ds = DAL_MysqlHelper.ExecuteDataTable(sql);
            }
            catch
            {
            }
            return(ds);
        }
Esempio n. 25
0
        /// <summary>
        /// 修改教师信息。
        /// </summary>
        /// <param name="teacher">修改后的教师实体信息</param>
        /// <returns></returns>
        public static bool modifyTeacher(Teacher teacher)
        {
            string username = teacher.username;
            string password = teacher.password;

            if (password.Length != 0)
            {
                password = DAL_Safety.getMD5(password);
            }
            string age = teacher.age;
            string sex = teacher.sex;

            try
            {
                string sql = "";
                int    res = 0;
                if (password.Length != 0)
                {
                    sql = "update teacher set password=?1, age=?2, sex=?3 where username=?4;";
                    MySqlParameter[] para = new MySqlParameter[4];
                    para[0] = new MySqlParameter("?1", password);
                    para[1] = new MySqlParameter("?2", age);
                    para[2] = new MySqlParameter("?3", username);
                    para[3] = new MySqlParameter("?4", username);
                    res     = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
                }
                else
                {
                    sql = "update teacher set  age=?1, sex=?2 where username=?3;";
                    MySqlParameter[] para = new MySqlParameter[3];
                    para[0] = new MySqlParameter("?1", age);
                    para[1] = new MySqlParameter("?2", sex);
                    para[2] = new MySqlParameter("?3", username);
                    res     = DAL_MysqlHelper.ExecuteNonQuery(sql, para);
                }
                if (res > 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception e)
            {
                LogWriter.writeLine("DAL.log", "modifyTeacher:" + e.Message);
                return(false);
            }
        }
Esempio n. 26
0
        public static DataSet queryMember(string TeamID)
        {
            string         sql  = "select b.username,b.major,a.AuditStatus from team_member a, users b where a.StuID=b.username and a.TeamID=?0";
            MySqlParameter para = new MySqlParameter("?0", TeamID);

            try
            {
                return(DAL_MysqlHelper.ExecuteDataTable(sql, para));
            }
            catch (Exception e)
            {
                return(null);
            }
        }
Esempio n. 27
0
        public static DataSet queryAllTeam()
        {
            DataSet ds = null;

            try
            {
                string sql = "select team.*,teacher.TeaName from teacher inner join team on teacher.username=team.TeaID";
                ds = DAL_MysqlHelper.ExecuteDataTable(sql);
            }
            catch
            {
            }
            return(ds);
        }
Esempio n. 28
0
 /// <summary>
 /// 查询销量降序排列的第pos条记录开始的连续length条记录
 /// </summary>
 /// <param name="pos"></param>
 /// <param name="length"></param>
 /// <returns></returns>
 public static DataSet QueryGoodsSellCountDesc(int pos, int length)
 {
     try
     {
         string           sql  = "select * from tb_goods order by sellCount limit ?st,?ed;";
         MySqlParameter[] para = new MySqlParameter[2];
         para[0] = new MySqlParameter("?st", pos);
         para[1] = new MySqlParameter("?ed", length);
         DataSet ds = DAL_MysqlHelper.ExecuteDataSet(sql, para);
         return(ds);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 29
0
 public static DataSet QueryManagers(int pos, int length)
 {
     try
     {
         string           sql  = "select managerName from tb_manage limit ?st,?ed;";
         MySqlParameter[] para = new MySqlParameter[2];
         para[0] = new MySqlParameter("?st", pos);
         para[1] = new MySqlParameter("?ed", length);
         var ret = DAL_MysqlHelper.ExecuteDataSet(sql, para);
         return(ret);
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 30
0
        /// <summary>
        /// 根据ID删除一个学生。
        /// </summary>
        /// <param name="ID">要删除的学生ID</param>
        /// <returns></returns>
        public static bool deleteStudentByID(string ID)
        {
            string sql = "delete from users where id=?1";

            MySqlParameter[] para = new MySqlParameter[1];
            para[0] = new MySqlParameter("?1", ID);
            int res = DAL_MysqlHelper.ExecuteNonQuery(sql, para);

            if (res > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }