Пример #1
0
        public static DataSet SelectBookInfoTable(int mode, string str)
        {
            string SqlStr = "SELECT Book.图书号,书名,作者,出版社,图书分类,存货,价格 AS 原价,标价 FROM BookInfo JOIN Book ON BookInfo.图书号=Book.图书号";

            if (mode == 0)
            {
                SqlStr = "SELECT Book.图书号,书名,作者,出版社,图书分类,存货,价格 AS 原价,标价 FROM BookInfo JOIN Book ON BookInfo.图书号=Book.图书号";
            }
            else if (mode == 1)
            {
                SqlStr = "SELECT Book.图书号,书名,作者,出版社,图书分类,存货,价格 AS 原价,标价 FROM BookInfo JOIN Book ON BookInfo.图书号=Book.图书号 WHERE 图书分类 LIKE \'" + str + "\'";
            }
            else if (mode == 2)
            {
                SqlStr = "SELECT Book.图书号,书名,作者,出版社,图书分类,存货,价格 AS 原价,标价 FROM BookInfo JOIN Book ON BookInfo.图书号=Book.图书号 WHERE 书名 LIKE \'" + str + "\'";
            }
            else if (mode == 3)
            {
                SqlStr = "SELECT Book.图书号,书名,作者,出版社,图书分类,存货,价格 AS 原价,标价 FROM BookInfo JOIN Book ON BookInfo.图书号=Book.图书号 WHERE 出版社 LIKE \'" + str + "\'";
            }
            else if (mode == 4)
            {
                SqlStr = "SELECT Book.图书号,书名,作者,出版社,图书分类,存货,价格 AS 原价,标价 FROM BookInfo JOIN Book ON BookInfo.图书号=Book.图书号 WHERE 作者 LIKE \'" + str + "\'";
            }
            return(MySQLConnector.GetInstance().Select(SqlStr));
        }
Пример #2
0
        public static DataSet ShowIncomeStat(int mode)
        {
            string SqlStr = "";

            if (mode == 0)
            {
                SqlStr = "SELECT year(交易时间) 年,sum(收款金额) AS 销售合计 FROM SellList GROUP BY year(交易时间)";
            }
            else if (mode == 1)
            {
                SqlStr = "SELECT year(交易时间) 年,month(交易时间) 月,day(交易时间) 日,sum(收款金额) AS 销售合计 FROM SellList GROUP BY year(交易时间),month(交易时间),day(交易时间)";
            }
            else if (mode == 2)
            {
                SqlStr = "SELECT year(交易时间) 年,month(交易时间) 月,sum(收款金额) AS 销售合计 FROM SellList GROUP BY year(交易时间),month(交易时间)";
            }
            else if (mode == 3)
            {
                SqlStr = "select year(交易时间) 年份, " +
                         "case when month(交易时间) between 1 and 3 then '一季度' " +
                         "when month(交易时间) between 4 and 6 then '二季度' " +
                         "when month(交易时间) between 7 and 9 then '三季度' " +
                         "when month(交易时间) between 10 and 12 then '四季度' end 季度, " +
                         "sum(收款金额) 金额 " +
                         "from SellList " +
                         "where year(交易时间) between 1970 and 2030 " +
                         "group by year(交易时间), " +
                         "case when month(交易时间) between 1 and 3 then '一季度' " +
                         "when month(交易时间) between 4 and 6 then '二季度' " +
                         "when month(交易时间) between 7 and 9 then '三季度' " +
                         "when month(交易时间) between 10 and 12 then '四季度' end ";
            }
            return(MySQLConnector.GetInstance().Select(SqlStr));
        }
Пример #3
0
        public static void ChangePrice(string isbn, string price)
        {
            int affected_row = MySQLConnector.GetInstance().Update(
                "UPDATE Book SET 标价=\'" + price + "\' WHERE 图书号=\'" + isbn + "\'"
                );

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #4
0
        public static void UpgradeVipLevel(string num)
        {
            int affected_row = MySQLConnector.GetInstance().Update(
                "UPDATE VipList SET 会员等级=1+(SELECT 会员等级 FROM VipList WHERE 编号=\'" + num + "\') WHERE 编号=\'" + num + "\'"
                );

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #5
0
        public static void AddToSellList(long vipNum, string iSBN, string time, int num, double money, string tranMode, string tranNum, string remarks)
        {
            int affected_row = MySQLConnector.GetInstance().Insert(
                "INSERT INTO SellList VALUES(\'" + vipNum + "\',\'" + iSBN + "\',\'" + time + "\',\'" + num + "\',\'" + money + "\',\'" + tranMode + "\',\'" + tranNum + "\',\'" + remarks + "\')"
                );

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #6
0
        public static void AddNewSysUser(string name, string pwd, string power)
        {
            int affected_row = MySQLConnector.GetInstance().Insert(
                "INSERT INTO AdminList VALUES(\'" + name + "\',\'" + pwd + "\',\'" + power + "\',NULL)"
                );

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #7
0
        public static void ChangeDiscount(int mode, string text)
        {
            int affected_row = MySQLConnector.GetInstance().Update(
                "UPDATE VipType SET 优惠折扣=\'" + text + "\' WHERE 等级=\'" + mode + "\'"
                );

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #8
0
        public static String FindBestSellingBook(string starttime, string endtime)
        {
            DataSet ds = MySQLConnector.GetInstance().Select(
                "SELECT * FROM (SELECT R.图书号,书名,MAX(销量) AS 销量 FROM BookInfo AS B JOIN (SELECT 图书号,SUM(数量) AS 销量 FROM SellList WHERE 交易时间 BETWEEN \'" + starttime + "\'AND \'" + endtime + "\' GROUP BY 图书号) AS R ON R.图书号=B.图书号 GROUP BY R.图书号,书名) AS R1 WHERE 销量=( SELECT MAX(R.销量) FROM (SELECT R.图书号,书名,MAX(销量) AS 销量 FROM BookInfo AS B JOIN (SELECT 图书号,SUM(数量) AS 销量 FROM SellList WHERE 交易时间 BETWEEN \'" + starttime + "\'AND \'" + endtime + "\' GROUP BY 图书号) AS R ON R.图书号=B.图书号 GROUP BY R.图书号,书名) AS R )"
                );
            String str = (ds.Tables[0].Rows[0].ItemArray[0].ToString() + "  " + ds.Tables[0].Rows[0].ItemArray[1].ToString() + "  " + ds.Tables[0].Rows[0].ItemArray[2].ToString());

            return(str);
        }
Пример #9
0
        public static int InquireBookNumbers(string iSBN)
        {
            int     num = 0;
            DataSet ds  = MySQLConnector.GetInstance().Select(
                "SELECT 存货 FROM Book WHERE 图书号='" + iSBN + "'"
                );

            num = int.Parse(ds.Tables[0].Rows[0].ItemArray[0].ToString());
            return(num);
        }
Пример #10
0
        public static void AddNewVip(string num, string name, string pwd_sha1, string phone, string mail)
        {
            String SqlStem = "INSERT INTO VipList VALUES(\'" + num + "\',\'" + name + "\',\'" + pwd_sha1 + "\',\'" + phone + "\',NULL,\'1\',NULL)";

            if (mail.Equals(""))
            {
                SqlStem = "INSERT INTO VipList VALUES(\'" + num + "\',\'" + name + "\',\'" + pwd_sha1 + "\',\'" + phone + "\',\'" + mail + "\',\'1\',NULL)";
            }
            int affected_row = MySQLConnector.GetInstance().Insert(SqlStem);

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #11
0
        public static void ChangeVipInfo(string num, string name, string pwd_sha1, string phone, string mail)
        {
            String SqlStem = "UPDATE VipList SET 用户名=\'" + name + "\',密码=\'" + pwd_sha1 + "\',邮箱=  NULL  ,手机号=\'" + phone + "\' WHERE 编号=\'" + num + "\'";

            if (mail.Equals(""))
            {
                SqlStem = "UPDATE VipList SET 用户名=\'" + name + "\',密码=\'" + pwd_sha1 + "\',邮箱=\'" + mail + "\',手机号=\'" + phone + "\' WHERE 编号=\'" + num + "\'";
            }

            int affected_row = MySQLConnector.GetInstance().Update(SqlStem);

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #12
0
        public static void AddNewBooks(string iSBN, string bookname, string authorname, string publishname, string classificationname, double money, string remarks)
        {
            int affected_row = 0;

            affected_row += MySQLConnector.GetInstance().Insert(
                "INSERT INTO BookInfo VALUES(\'" + iSBN + "\',\'" + bookname + "\',\'" + authorname + "\',\'" + publishname + "\',\'" + classificationname + "\',\'" + money + "\',\'" + remarks + "\')"
                );
            affected_row += MySQLConnector.GetInstance().Insert(
                "INSERT INTO Book VALUES(\'" + iSBN + "\',\'" + "0" + "\',\'" + money + "\',\'" + remarks + "\')"
                );

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #13
0
        public static void ChangeAdminPwd(string oldpwd_sha1, string newpwd_sha1)
        {
            String SqlStem      = "UPDATE AdminList SET 密码 = \'" + newpwd_sha1 + "\'WHERE 用户名 = \'" + LoginInfo.LoginName + "\'" + " AND 密码 = \'" + oldpwd_sha1 + "\'";
            int    affected_row = MySQLConnector.GetInstance().Update(SqlStem);

            if (affected_row == 1)
            {
                MessageBox.Show("修改成功,Update, Total rows affected:1");
            }
            else
            {
                MessageBox.Show("修改失败,Update, Total rows affected:0");
            }
        }
Пример #14
0
        public static void ExecuteStem(String SqlStem)
        {
            int affected_row = MySQLConnector.GetInstance().Insert(SqlStem);

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
            ;
            if (affected_row == 1)
            {
                MessageBox.Show("执行成功");
            }
            else
            {
                MessageBox.Show("执行失败");
            }
        }
Пример #15
0
        public static void Replenishment(int mode, string isbn, int num)
        {
            String SqlStem = "";

            if (mode == 1)//修改
            {
                SqlStem = "UPDATE Book SET 存货 = \'" + num + "\'WHERE 图书号 = \'" + isbn + "\'";
            }
            else if (mode == 2)
            {//增加
                SqlStem = "UPDATE Book SET 存货 = \'" + num + "\'+ (SELECT 存货 FROM Book WHERE 图书号 = \'" + isbn + "\') WHERE 图书号 = \'" + isbn + "\'";
            }
            int affected_row = MySQLConnector.GetInstance().Update(SqlStem);

            MessageBox.Show("INSERT, Total rows affected:" + affected_row);
        }
Пример #16
0
 /// <summary>
 /// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
 /// </summary>
 /// <returns></returns>
 public static MySQLConnector GetInstance()
 {
     // 当第一个线程运行到这里时,此时会对locker对象 "加锁",
     // 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
     // lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
     // 双重锁定只需要一句判断就可以了
     if (uniqueInstance == null)
     {
         lock (locker)
         {
             // 如果类的实例不存在则创建,否则直接返回
             if (uniqueInstance == null)
             {
                 uniqueInstance = new MySQLConnector();
             }
         }
     }
     return(uniqueInstance);
 }
Пример #17
0
 public static DataSet ShowAllDiscounts()
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT * FROM VipType"
                ));
 }
Пример #18
0
 public static string GetPower(string name)
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT 权限 FROM AdminList WHERE 用户名='" + name + "'"
                ).Tables[0].Rows[0].ItemArray[0].ToString());
 }
Пример #19
0
 public static DataSet SelectVipSumBuy(string vipnum)
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT 交易人编号,SUM(收款金额) AS 总消费金额 FROM SellList WHERE 交易人编号<>0 AND 交易人编号 LIKE '" + vipnum + "'  GROUP BY 交易人编号"
                ));
 }
Пример #20
0
 public static DataSet SelectVipTTable()
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT 编号,用户名,密码 AS '密码(已加密)',手机号,邮箱,会员等级 FROM VipList"
                ));
 }
Пример #21
0
 public static DataSet SelectBookTable()
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT Book.图书号,书名,存货,标价 FROM Book JOIN BookInfo ON Book.图书号=BookInfo.图书号"
                ));
 }
Пример #22
0
 public static DataSet ShowSalesReport(string starttime, string endtime)
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT R.图书号,书名,MAX(销量) AS 销量 FROM BookInfo AS B JOIN (SELECT 图书号,SUM(数量) AS 销量 FROM SellList WHERE 交易时间 BETWEEN \'" + starttime + "\'AND \'" + endtime + "\' GROUP BY 图书号) AS R ON R.图书号=B.图书号 GROUP BY R.图书号,书名"
                ));
 }
Пример #23
0
 public static String GetNewVipNum()
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT MAX(编号)+1 FROM VipList"
                ).Tables[0].Rows[0].ItemArray[0].ToString());
 }
Пример #24
0
 public static String Get_Pwd(String str)
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT 密码 FROM AdminList WHERE 用户名='" + str + "'"
                ).Tables[0].Rows[0].ItemArray[0].ToString());
 }
Пример #25
0
 public static DataSet GetAllEmails()
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT 邮箱 FROM VipList WHERE 邮箱 IS NOT NULL "
                ));
 }
Пример #26
0
 public static DataSet ShowAllSysUsers()
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT 用户名,权限,备注 FROM AdminList"
                ));
 }
Пример #27
0
 public static string GetPrice(string isbn)
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT 标价 FROM Book WHERE 图书号='" + isbn + "'"
                ).Tables[0].Rows[0].ItemArray[0].ToString());
 }
Пример #28
0
 public static DataSet SelectSellListTable(string starttime, string endtime)
 {
     return(MySQLConnector.GetInstance().Select(
                "SELECT * FROM SellList WHERE 交易时间 BETWEEN \'" + starttime + "\' AND \'" + endtime + "\'"
                ));
 }