Пример #1
0
        private string InsertNewBookInfo(bookinfo bi)
        {
            if (null == bi)
            {
                return("");
            }

            try
            {
                string sql = string.Format("INSERT INTO tt_bookinfo (id,gbookid,name,author,press,price,ISBN,imgpath) VALUES (null,'{0}','{1}','{2}','{3}','{4}','{5}','{6}')",
                                           bi.gbookid, bi.name, bi.author, bi.press, bi.price, bi.isbn, bi.imgpath);
                if (dbo.AddDelUpdate(sql) == 1)
                {
                    sql = "SELECT id FROM tt_bookinfo WHERE isbn ='" + bi.isbn + "'";
                    DataTable dt = dbo.Selectinfo(sql);
                    return(dt.Rows[0]["id"].ToString());
                }
                else
                {
                    MyOperation.MessageShow("同步教材信息至本地时发生错误,请联系管理员处理");
                    return("");
                }
            }
            catch (Exception e)
            {
                MyOperation.DebugPrint("InsertNewBookInfo出现catch异常:" + e.Message, 3);
            }
            return("");
        }
Пример #2
0
 private Boolean PraseHtml(string html, out bookinfo bookinfo)
 {
     bookinfo = new bookinfo();
     if ("" == html || "{\"result\":0,\"data\":null}" == html)
     {
         MyOperation.DebugPrint("没有找到对应的图书信息", 1);
         DisplayAll(0);
         return(false);
     }
     try
     {
         JObject jo1 = (JObject)JsonConvert.DeserializeObject(html);
         bookinfo.gbookid = jo1["data"]["id"].ToString();
         bookinfo.name    = jo1["data"]["name"].ToString();
         bookinfo.author  = jo1["data"]["author"].ToString();
         bookinfo.imgpath = jo1["data"]["imgpath"].ToString();
         bookinfo.press   = jo1["data"]["press"].ToString();
         bookinfo.price   = jo1["data"]["fixedPrice"].ToString();
         bookinfo.isbn    = jo1["data"]["isbn"].ToString();
         DisplayAll(1);
         return(true);
     }
     catch (Exception e)
     {
         MyOperation.DebugPrint("PraseHtml:出现catch异常:" + e.Message);
         DisplayAll(0);
         return(false);
     }
 }
Пример #3
0
        //书主信息表
        private void button4_Click(object sender, RoutedEventArgs e)
        {
            string sql = "SELECT ts.sellerid AS `书主号`,ts.`name` AS `姓名`,ts.phone AS `手机`," +
                         "ts.grade AS `年级`,ts.mark AS `备注` FROM tt_sellerinfo AS ts";
            DataTable dt = dbo.Selectinfo(sql);

            MyOperation.DebugPrint("导出了全部书主信息");
            ExcelOperation.SendToExcel(dt, "书主信息表");
        }
Пример #4
0
        //导出全部员工信息
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            string sql = "SELECT ts.staffid AS `员工号`,ts.`name` AS `姓名`,ts.email AS `邮箱`,ts.phone AS `手机`," +
                         "ts.role AS `角色`,ts.mark AS `备注` FROM tt_staffinfo AS ts";
            DataTable dt = dbo.Selectinfo(sql);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["角色"] = ("admin" == dt.Rows[i]["角色"].ToString()) ? "管理员" : "员工";
            }
            MyOperation.DebugPrint("导出了全部员工信息");
            ExcelOperation.SendToExcel(dt, "员工信息表");
        }
Пример #5
0
        //可以刷新当前实时余额以及出售数量
        private string get_money2()
        {
            string    sql       = "SELECT date,money FROM tt_fanance ORDER BY date DESC LIMIT 0,1";
            DataTable dt        = dbo.Selectinfo(sql);
            float     count_old = 0;
            string    datetime  = "";

            if (dt.Rows.Count == 1)
            {
                count_old = float.Parse(dt.Rows[0]["money"].ToString());
                datetime  = dt.Rows[0]["date"].ToString();
            }
            else
            {
                datetime = "2000/1/1 00:00:00";
            }
            float count1 = 0;

            //计算该班次出售的数量
            sql = string.Format("SELECT count(*) FROM tt_sellinfo WHERE issold = '1' AND soldtime > '{0}'  GROUP BY NULL", datetime);
            dt  = dbo.Selectinfo(sql);
            if (dt.Rows.Count == 1)
            {
                lb_thiscount.Content = dt.Rows[0][0].ToString();
            }
            else
            {
                lb_thiscount.Content = "数量异常";
            }
            //先计算出售信息
            sql = string.Format("SELECT SUM(price) FROM tt_sellinfo WHERE issold = '1' AND soldtime > '{0}'  GROUP BY NULL", datetime);
            dt  = dbo.Selectinfo(sql);
            if (dt.Rows.Count == 1)
            {
                count1 = float.Parse(dt.Rows[0][0].ToString());
            }

            float count2 = 0;

            //再计算提款信息
            sql = string.Format("SELECT SUM(count) FROM tt_tikuan WHERE date > '{0}'  GROUP BY NULL", datetime);
            dt  = dbo.Selectinfo(sql);
            if (dt.Rows.Count == 1)
            {
                count2 = float.Parse(dt.Rows[0][0].ToString());
            }
            MyOperation.DebugPrint("前日剩余:" + count_old.ToString() + "今日收入:" + count1.ToString() + "今日支出:" + count2.ToString());
            return((count_old + count1 - count2).ToString());
        }
Пример #6
0
        private void button7_Click(object sender, RoutedEventArgs e)
        {
            if (null == datePicker5.SelectedDate || null == datePicker6.SelectedDate)
            {
                MyOperation.MessageShow("请选择开始和结束日期");
                return;
            }

            string sql = string.Format("SELECT tt_fanance.money AS `余额`, tt_fanance.date AS `结算时间` FROM tt_fanance " +
                                       "WHERE date > '{0}' AND date < '{1}'", datePicker5.SelectedDate, datePicker6.SelectedDate);
            DataTable dt = dbo.Selectinfo(sql);

            MyOperation.DebugPrint("导出了现金流向信息");
            ExcelOperation.SendToExcel(dt, "现金详情表");
        }
Пример #7
0
 private void tb_sellidsearch_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.Enter)
         {
             SearchSellinfo();
             e.Handled = true;
         }
     }
     catch (Exception e1)
     {
         MyOperation.DebugPrint(e1.Message);
     }
 }
Пример #8
0
 private void tb_price_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.Enter)
         {
             ChangePrice();
             e.Handled = true;
         }
     }
     catch (Exception e1)
     {
         MyOperation.DebugPrint(e1.Message);
     }
 }
Пример #9
0
        //按时间导出取现信息
        private void button5_Click(object sender, RoutedEventArgs e)
        {
            if (null == datePicker1.SelectedDate || null == datePicker2.SelectedDate)
            {
                MyOperation.MessageShow("请选择开始和结束日期");
                return;
            }

            string sql = string.Format("SELECT ts.`name` AS `姓名`,tt.count AS `数额`,tt.date AS `提款时间` FROM tt_tikuan AS tt ," +
                                       "tt_sellerinfo AS ts WHERE tt.sellerid = ts.sellerid AND tt.date > '{0}' AND tt.date < '{1}'", datePicker1.SelectedDate, datePicker2.SelectedDate);
            DataTable dt = dbo.Selectinfo(sql);

            MyOperation.DebugPrint("导出了取现信息");
            ExcelOperation.SendToExcel(dt, "取现详情表");
        }
Пример #10
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb1.Text))
            {
                MyOperation.MessageShow("请输入书主号");
                tb1.Focus();
                return;
            }
            string sql = string.Format("SELECT ts.`name` AS `姓名`,tt.count AS `数额`,tt.date AS `提款时间` " +
                                       "FROM tt_tikuan AS tt ,tt_sellerinfo AS ts WHERE tt.sellerid = ts.sellerid AND ts.sellerid = '{0}'", tb1.Text);
            DataTable dt = dbo.Selectinfo(sql);

            MyOperation.DebugPrint("导出了取现信息:" + tb1.Text);
            ExcelOperation.SendToExcel(dt, string.Format("书主【{0}】取现详情表", tb1.Text));
        }
Пример #11
0
        private void DisplayBookinfo(bookinfo bi)
        {
            if (null == bi)
            {
                return;
            }
            try
            {
                lbb_bookid.Content = "内部编号:" + bi.bookid;
                lbb_author.Content = "作者:" + bi.author;
                lbb_ISBN.Content   = "ISBN:" + bi.isbn;
                lbb_name.Content   = "书名:" + bi.name;
                lbb_press.Content  = "出版社:" + bi.press;
                lbb_price.Content  = "定价:" + bi.price;
                //====================标准image source添加方法=====================
                // Create source
                BitmapImage myBitmapImage = new BitmapImage();

                // BitmapImage.UriSource must be in a BeginInit/EndInit block
                myBitmapImage.BeginInit();
                myBitmapImage.UriSource = new Uri(@bi.imgpath, UriKind.Absolute);

                // To save significant application memory, set the DecodePixelWidth or
                // DecodePixelHeight of the BitmapImage value of the image source to the desired
                // height or width of the rendered image. If you don't do this, the application will
                // cache the image as though it were rendered as its normal size rather then just
                // the size that is displayed.
                // Note: In order to preserve aspect ratio, set DecodePixelWidth
                // or DecodePixelHeight but not both.
                myBitmapImage.DecodePixelWidth = 250;
                myBitmapImage.EndInit();
                //set image source
                bookimage.Source = myBitmapImage;
                DisplayAll(1);
            }
            catch (UriFormatException e)
            {
                MyOperation.DebugPrint("DisplayBookinfo未能解析URL:" + e.Message, 1);
                bookimage.Source = new BitmapImage(new Uri(@"/images/defaultbookimg.jpg", UriKind.RelativeOrAbsolute));
                DisplayAll(1);
            }
            catch (Exception e)
            {
                MyOperation.DebugPrint("DisplayBookinfo出现catch异常:" + e.Message, 3);
                DisplayAll(2);
                MyOperation.MessageShow("系统异常,请联系管理员处理");
            }
        }
Пример #12
0
            public void ThreadProc()
            {
                DBOperation dbo = new DBOperation();
                YouGeWebApi ygw = new YouGeWebApi();

                if (string.IsNullOrEmpty(_book_id))
                {
                    throw new Exception("book_id is null!");
                }
                if (string.IsNullOrEmpty(_price))
                {
                    throw new Exception("price is null!");
                }
                //判断本地是否有相同book_id和price的交易记录,如果有就全部同步成一个mallid,不要再上报给喵校园主库
                string sql = string.Format("SELECT tt_bookinfo.id,tt_sellinfo.mallid FROM tt_bookinfo ,tt_sellinfo WHERE tt_bookinfo.id " +
                                           "= tt_sellinfo.bookid AND tt_bookinfo.gbookid ='{0}' AND ABS(tt_sellinfo.price- {1}) < 1e-5  AND tt_sellinfo.mallid IS NOT NULL",
                                           _book_id, _price);
                DataTable dt = dbo.Selectinfo(sql);

                //如果有,则直接全部更新一次mallid,不用上报给喵校园主库
                if (dt.Rows.Count > 0)
                {
                    sql = string.Format("UPDATE tt_sellinfo SET mallid = '{0}' WHERE bookid = '{1}' AND ABS(price- {2}) < 1e-5",
                                        dt.Rows[0]["mallid"].ToString(), dt.Rows[0]["id"].ToString(), _price);
                    dbo.AddDelUpdate(sql);
                    return;
                }
                //如果没有,则添加到喵校园主库,返回交易ID后,同步到每一条符合条件的交易中
                string sellinfoid;//喵校园交易ID
                IDictionary <string, string> parameters = new Dictionary <string, string>();

                parameters.Add("book_id", _book_id);
                parameters.Add("price", _price);
                parameters.Add("seller_id", Properties.Settings.Default.sellerid);
                if (ygw.InsertNewSellInfo(parameters, out sellinfoid))
                {
                    sql = string.Format("UPDATE tt_sellinfo SET mallid = '{0}' WHERE bookid = '{1}' AND ABS(price- {2}) < 1e-5",
                                        sellinfoid, _local_book_id, _price);
                    dbo.AddDelUpdate(sql);
                    MessageBox.Show("执行完成");
                    return;
                }
                else
                {
                    MyOperation.DebugPrint("Insert Error!", 3);
                    throw new Exception("Insert Error!");
                }
            }
Пример #13
0
        private void button8_Click(object sender, RoutedEventArgs e)
        {
            if (null == datePicker7.SelectedDate || null == datePicker8.SelectedDate)
            {
                MyOperation.MessageShow("请选择开始和结束日期");
                return;
            }

            string sql = string.Format("SELECT ts.`name` AS `姓名`,tt.time AS `时长`,tt.group AS `班次`,tt.date AS `签到时间`," +
                                       "tt.mark AS `备注` FROM tt_time AS tt ,tt_staffinfo AS ts WHERE ts.staffid = tt.staffid AND tt.date > '{0}' AND " +
                                       "tt.date < '{1}'", datePicker7.SelectedDate, datePicker8.SelectedDate);
            DataTable dt = dbo.Selectinfo(sql);

            MyOperation.DebugPrint("导出了工时信息");
            ExcelOperation.SendToExcel(dt, "工时详情表");
        }
Пример #14
0
 private void UserControl_KeyDown(object sender, KeyEventArgs e)
 {
     try
     {
         if (e.Key == Key.F5)
         {
             Display();
             e.Handled = true;
         }
     }
     catch (Exception e1)
     {
         MyOperation.DebugPrint("结账下班界面刷新时出现了异常" + e1.Message);
         MyOperation.MessageShow("结账下班界面刷新时出现了异常" + e1.Message);
     }
 }
Пример #15
0
        //出售信息详情表
        private void button6_Click(object sender, RoutedEventArgs e)
        {
            if (null == datePicker3.SelectedDate || null == datePicker4.SelectedDate)
            {
                MyOperation.MessageShow("请选择开始和结束日期");
                return;
            }

            string sql = string.Format("SELECT tb.`name` AS `书名`,tb.press AS `出版社`,ts.sellinfoid AS `图书ID`,ts.price " +
                                       "AS `售价`,tsr.sellerid AS `书主ID`,tsr.`name` AS `书主`,ts.soldtime AS `出售时间` FROM tt_sellinfo AS ts ," +
                                       "tt_bookinfo AS tb ,tt_sellerinfo AS tsr WHERE ts.sellerid = tsr.sellerid AND ts.bookid = tb.id AND ts.soldtime" +
                                       " > '{0}' AND ts.soldtime < '{1}'", datePicker3.SelectedDate, datePicker4.SelectedDate);
            DataTable dt = dbo.Selectinfo(sql);

            MyOperation.DebugPrint("导出了出售信息");
            ExcelOperation.SendToExcel(dt, "出售详情表");
        }
Пример #16
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb1.Text))
            {
                MyOperation.MessageShow("请输入书主号");
                tb1.Focus();
                return;
            }
            string sql = string.Format("SELECT s.sellinfoid AS `图书ID`,b.`name` AS `书名`,b.press AS `出版社`,s.price AS `售价`," +
                                       "s.issold AS `是否已售` FROM tt_sellinfo AS s , tt_bookinfo AS b WHERE s.bookid = b.id AND " +
                                       "s.sellerid = '{0}'", tb1.Text);
            DataTable dt = dbo.Selectinfo(sql);

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt.Rows[i]["是否已售"] = ("0" == dt.Rows[i]["是否已售"].ToString()) ? "否" : "是";
            }
            MyOperation.DebugPrint("导出了书主信息:" + tb1.Text);
            ExcelOperation.SendToExcel(dt, string.Format("书主【{0}】交易详情表", tb1.Text));
        }
Пример #17
0
 void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     try
     {
         string sellinfoid = e.ToString();
         //需要先判断本地是否还有尚未出售的交易
         string    sql = string.Format("SELECT bookid,price, mallid FROM tt_sellinfo WHERE sellinfoid = '{0}'", sellinfoid);
         DataTable dt  = dbo.Selectinfo(sql);
         if (dt.Rows.Count != 1)
         {
             //不等于1说明传进来的sellinfoid就有问题,直接异常
             MyOperation.DebugPrint("出售图书时,传入的sellinfoid异常:" + sellinfoid, 3);
             return;
         }
         string mallid = dt.Rows[0]["mallid"].ToString();
         sql = string.Format("SELECT mallid FROM tt_sellinfo WHERE issold = '0' AND mallid IS NOT NULL AND bookid = '{0}' AND price = '{1}'",
                             dt.Rows[0]["bookid"].ToString(), dt.Rows[0]["price"].ToString());
         dt = dbo.Selectinfo(sql);
         //如果有就不需要上报给喵校园,不需要任何处理,直接返回
         if (dt.Rows.Count > 0)
         {
             return;
         }
         //如果没有就上报给喵校园主库
         else if (!string.IsNullOrEmpty(mallid))
         {
             IDictionary <string, string> parameters = new Dictionary <string, string>();
             parameters.Add("status", "1");
             parameters.Add("id", mallid);
             ygw.InsertNewSellInfo(parameters, out sellinfoid);
         }
         else
         {
             MyOperation.DebugPrint("存在尚未出售但是没有mallid的交易信息:" + sellinfoid, 3);
         }
     }
     catch (Exception ex)
     {
         MyOperation.DebugPrint(ex.Message, 3);
     }
 }
Пример #18
0
 void backgroundWorker1_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
 {
     try
     {
         string[]  Args = e.ToString().Split('|');
         string    sql  = string.Format("SELECT mallid FROM tt_sellinfo WHERE sellinfoid = '{0}'", Args[0]);
         DataTable dt   = dbo.Selectinfo(sql);
         if (dt.Rows.Count == 1)
         {
             IDictionary <string, string> parameters = new Dictionary <string, string>();
             parameters.Add("price", Args[1]);
             parameters.Add("id", dt.Rows[0]["mallid"].ToString());
             string tmp;
             ygw.InsertNewSellInfo(parameters, out tmp);
         }
     }
     catch (Exception ex)
     {
         MyOperation.DebugPrint(ex.Message, 3);
     }
 }
Пример #19
0
        private void button4_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb1.Text))
            {
                MyOperation.MessageShow("必须输入书名");
                tb1.Focus();
                return;
            }
            if (string.IsNullOrEmpty(tb2.Text))
            {
                MyOperation.MessageShow("必须输入作者");
                tb2.Focus();
                return;
            }
            if (string.IsNullOrEmpty(tb3.Text))
            {
                MyOperation.MessageShow("必须输入出版社");
                tb3.Focus();
                return;
            }
            if (string.IsNullOrEmpty(tb5.Text))
            {
                MyOperation.MessageShow("必须输入ISBN");
                tb5.Focus();
                return;
            }
            if (string.IsNullOrEmpty(tb6.Text))
            {
                MyOperation.MessageShow("必须输入定价");
                tb6.Focus();
                return;
            }
            string url = "http://api.jige.olege.com/book";
            IDictionary <string, string> parameters = new Dictionary <string, string>();

            parameters.Add("isbn", tb5.Text);
            parameters.Add("fixedPrice", tb6.Text);
            parameters.Add("name", tb1.Text);
            parameters.Add("press", tb3.Text);
            parameters.Add("author", tb2.Text);
            Encoding        encoding = Encoding.GetEncoding("UTF-8");
            HttpWebResponse response = CreatePostHttpResponse(url, parameters, null, null, encoding, null);
            StreamReader    reader   = new StreamReader(response.GetResponseStream(), Encoding.Default);

            Char[] read = new Char[256];
            // Reads 256 characters at a time.
            int    count = reader.Read(read, 0, 256);
            String str   = "";

            while (count > 0)
            {
                // Dumps the 256 characters on a string and displays the string to the console.
                str = new String(read, 0, count);
                Console.Write(str);
                count = reader.Read(read, 0, 256);
            }
            MyOperation.DebugPrint("新增图书信息" + tb5.Text + tb6.Text + tb1.Text + tb3.Text + tb2.Text);
            MyOperation.DebugPrint("新增图书信息返回的JSON中data.id为:" + str, 3);

            try
            {
                JObject  jo1 = (JObject)JsonConvert.DeserializeObject(str);
                bookinfo bi  = new bookinfo();
                bi.author  = tb2.Text;
                bi.gbookid = jo1["data"].ToString();
                bi.imgpath = "";
                bi.isbn    = tb5.Text;
                bi.name    = tb1.Text;
                bi.press   = tb3.Text;
                bi.price   = tb6.Text;
                bi.bookid  = InsertNewBookInfo(bi);
                if ("" == bi.bookid)
                {
                    return;
                }
                MyOperation.MessageShow("添加成功!");
                DisplayBookinfo(bi);
            }
            catch (Exception ex)
            {
                MyOperation.DebugPrint("新增图书信息button4_Click:出现catch异常:" + ex.Message, 3);
                MyOperation.MessageShow("新增图书出现异常,请尝试重新搜索ISBN");
            }
        }
Пример #20
0
        //添加出售信息按钮
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb_isbn.Text))
            {
                MyOperation.MessageShow("请输入图书的ISBN号");
                tb_isbn.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_sellerid.Text))
            {
                MyOperation.MessageShow("请输入书主号");
                tb_sellerid.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_sellinfoid.Text))
            {
                MyOperation.MessageShow("请输入图书唯一ID");
                tb_sellinfoid.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_price.Text))
            {
                MyOperation.MessageShow("请输入出售价格");
                tb_price.Focus();
                return;
            }

            string    sql = string.Format("SELECT id,gbookid FROM tt_bookinfo WHERE ISBN = '{0}'", tb_isbn.Text);
            DataTable dt  = dbo.Selectinfo(sql);

            if (dt.Rows.Count == 0)
            {
                MyOperation.MessageShow("未找到该ISBN号的书籍,请首先在上方搜索对应信息");
                MyOperation.DebugPrint("未找到该ISBN号的书籍 " + sql, 3);
                return;
            }

            sql = string.Format("SELECT sellinfoid FROM tt_sellinfo WHERE sellinfoid = '{0}'", tb_sellinfoid.Text);
            DataTable dt1 = dbo.Selectinfo(sql);

            if (dt1.Rows.Count != 0)
            {
                MyOperation.MessageShow("已经存在该图书唯一ID【" + tb_sellinfoid.Text + "】,请更换后重试");
                return;
            }
            sql = string.Format("INSERT INTO tt_sellinfo (sellinfoid,sellerid,bookid,price,buyer,buytime,issold) VALUES ('{0}','{1}','{2}','{3}','{4}','{5}','{6}')",
                                tb_sellinfoid.Text, tb_sellerid.Text, dt.Rows[0]["id"].ToString(), tb_price.Text, App.login_staffid, DateTime.Now.ToString(), "0");
            if (1 == dbo.AddDelUpdate(sql))
            {
                MyOperation.MessageShow("添加成功");
            }
            else
            {
                MyOperation.MessageShow("添加失败");
                MyOperation.DebugPrint("添加交易信息时发生错误", 3);
                return;
            }

            //开始同步新的出售信息到喵校园主库
            ThreadWithState tws = new ThreadWithState(
                dt.Rows[0]["gbookid"].ToString(),
                tb_price.Text,
                dt.Rows[0]["id"].ToString()
                );

            Thread t = new Thread(new ThreadStart(tws.ThreadProc));

            t.IsBackground = true;
            t.Start();
            //原来在添加成功的分支中,现在移到线程建立完毕
            tb_sellinfoid.Text = tb_price.Text = "";
            tb_isbn.Focus();
        }
Пример #21
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb_name.Text))
            {
                MyOperation.MessageShow("请填写姓名");
                tb_name.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_phone.Text))
            {
                MyOperation.MessageShow("请填写手机");
                tb_phone.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_sellerid.Text))
            {
                MyOperation.MessageShow("请填写学号");
                tb_sellerid.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_email.Text))
            {
                MyOperation.MessageShow("请填写邮箱");
                tb_email.Focus();
                return;
            }

            if (string.IsNullOrEmpty(passwordBox1.Password))
            {
                MyOperation.MessageShow("请填写密码");
                passwordBox1.Focus();
                return;
            }

            if (string.IsNullOrEmpty(passwordBox2.Password))
            {
                MyOperation.MessageShow("请填写确认密码");
                passwordBox2.Focus();
                return;
            }

            if (passwordBox1.Password != passwordBox2.Password)
            {
                MyOperation.MessageShow("两次输入的密码不一致");
                passwordBox2.Focus();
                return;
            }

            string sql = string.Format("INSERT INTO tt_staffinfo (id,staffid,name,phone,password,email,mark,role) VALUES (null,'{0}','{1}','{2}','{3}','{4}','{5}','{6}')",
                                       tb_sellerid.Text, tb_name.Text, tb_phone.Text, MyOperation.MD5(passwordBox1.Password), tb_email.Text, tb_mark.Text, comboBox1.SelectedValue.ToString());

            if (1 != dbo.AddDelUpdate(sql))
            {
                MyOperation.MessageShow("添加新用户失败,请重新添加");
                return;
            }
            else
            {
                MyOperation.MessageShow("添加成功");
                MyOperation.DebugPrint("添加了新用户");
                tb_email.Text = tb_mark.Text = tb_name.Text = tb_phone.Text = tb_sellerid.Text = "";
                return;
            }
        }