Example #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("");
        }
Example #2
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!");
                }
            }
Example #3
0
        private void button3_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(textBox2.Text))
            {
                MyOperation.MessageShow("请先输入图书编号");
                textBox2.Focus();
                return;
            }

            string sql = string.Format("UPDATE tt_sellinfo SET issold = 1 ,seller = '{0}',soldtime = '{1}' WHERE sellinfoid = '{2}' AND issold = '0'", "123", DateTime.Now.ToString("G"), textBox2.Text);

            if (dbo.AddDelUpdate(sql) != 1)
            {
                MyOperation.MessageShow(string.Format("没有查到图书唯一ID为【{0}】并且尚未出售的交易,请在上方查询详细信息", textBox2.Text));
                textBox2.Focus();
                return;
            }
            else
            {
                MyOperation.MessageShow("出售成功!");
                textBox2.Focus();
            }

            backgroundWorker1         = new System.ComponentModel.BackgroundWorker();
            backgroundWorker1.DoWork += backgroundWorker1_DoWork;
            string sellinfoid = textBox2.Text;

            backgroundWorker1.RunWorkerAsync(sellinfoid);
        }
Example #4
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb_staffid.Text))
            {
                MyOperation.MessageShow("请填写员工工号!");
                tb_staffid.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_time.Text))
            {
                MyOperation.MessageShow("请填写工时");
                tb_time.Focus();
                return;
            }

            string sql = string.Format("INSERT INTO tt_time (`id`,`group`,`time`,`staffid`,`mark`,`date`) VALUES (null,'{0}','{1}','{2}','{3}','{4}')", comboBox1.Text, tb_time.Text, tb_staffid.Text, tb_mark.Text, DateTime.Now);

            if (1 == dbo.AddDelUpdate(sql))
            {
                MyOperation.MessageShow("添加成功");
                tb_mark.Text = tb_staffid.Text = tb_time.Text = "";
                return;
            }
            else
            {
                MyOperation.MessageShow("添加失败,请重试");
                return;
            }
        }
Example #5
0
        private void button4_Click(object sender, RoutedEventArgs e)
        {
            string sql = string.Format("INSERT INTO tt_tikuan (sellerid,count,date) VALUES ('{0}','{1}','{2}')", textBox2.Text, textBox3.Text, DateTime.Now);

            dbo.AddDelUpdate(sql);
            displayye(textBox2.Text);
        }
Example #6
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb_title.Text))
            {
                MyOperation.MessageShow("请填写完整的公告标题");
                tb_title.Focus();
                return;
            }

            if (string.IsNullOrEmpty(tb_context.Text))
            {
                MyOperation.MessageShow("请填写完整的公告内容");
                tb_context.Focus();
                return;
            }
            string sql = string.Format("INSERT INTO tt_notice (id,title,context) VALUES (null,'{0}','{1}')", tb_title.Text, tb_context.Text);

            if (dbo.AddDelUpdate(sql) == 1)
            {
                MyOperation.MessageShow("添加成功");
                tb_title.Text   = "";
                tb_context.Text = "";
            }
            else
            {
                MyOperation.MessageShow("添加失败,请重试");
            }
        }
Example #7
0
        private void button2_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb_name.Text))
            {
                MyOperation.MessageShow("没有输入内容");
                this.tb_name.Focus();
                return;
            }
            string sql = string.Format("UPDATE tt_sellerinfo SET `name` = '{0}' WHERE `sellerid` = '{1}'", tb_name.Text, sellerid);

            if (1 == dbo.AddDelUpdate(sql))
            {
                MyOperation.MessageShow("修改成功!");
            }
            else
            {
                MyOperation.MessageShow("修改失败!");
            }
        }
Example #8
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(tb_sellerid.Text) || tb_sellerid.Text.Length != 8)
            {
                MyOperation.MessageShow("请填写正确的书主号,长度8位");
                tb_sellerid.Focus();
                return;
            }
            else
            {
                string    sqls = string.Format("SELECT * FROM tt_sellerinfo WHERE sellerid = '{0}'", tb_sellerid.Text);
                DataTable dt   = dbo.Selectinfo(sqls);
                if (dt.Rows.Count > 0)
                {
                    MyOperation.MessageShow("该书主号已经存在");
                    tb_sellerid.Focus();
                    return;
                }
            }

            if (string.IsNullOrEmpty(tb_name.Text))
            {
                MyOperation.MessageShow("请填写完整的姓名");
                tb_name.Focus();
                return;
            }

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

            string sql = string.Format("INSERT INTO tt_sellerinfo (id,sellerid,name,phone,grade,mark) VALUES (null,'{0}','{1}','{2}','{3}','{4}')",
                                       tb_sellerid.Text, tb_name.Text, tb_phone.Text, tb_grade.Text, tb_mark.Text);

            if (dbo.AddDelUpdate(sql) == 1)
            {
                MyOperation.MessageShow("添加成功");
                tb_sellerid.Text = tb_name.Text = tb_phone.Text = tb_mark.Text = tb_grade.Text = "";
            }
            else
            {
                MyOperation.MessageShow("添加失败,请重试");
            }
        }
Example #9
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            //string ye = get_money2();
            if (string.IsNullOrEmpty(textBox1.Text))
            {
                MyOperation.MessageShow("请输入当前现金余额");
                return;
            }
            string ye  = textBox1.Text;
            string sql = string.Format("INSERT INTO tt_fanance (money,date) VALUES ('{0}','{1}')", ye, DateTime.Now);

            if (1 != dbo.AddDelUpdate(sql))
            {
                MyOperation.MessageShow("结账失败,请联系管理员处理");
            }
            else
            {
                MyOperation.MessageShow("结账成功,可以下班了!");
            }
        }
Example #10
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;
            }
        }
        private void ChangePrice()
        {
            if (string.IsNullOrEmpty(tb_price.Text))
            {
                MyOperation.MessageShow("请输入新的价格");
                tb_price.Focus();
                return;
            }

            if (sellinfoid == "")
            {
                MyOperation.MessageShow("请先在上方查询出要修改的交易信息");
                tb_sellidsearch.Focus();
                return;
            }
            string sql = string.Format("UPDATE tt_sellinfo SET price = '{0}' WHERE sellinfoid = '{1}'", tb_price.Text, sellinfoid);

            if (1 == dbo.AddDelUpdate(sql))
            {
                MyOperation.MessageShow("修改成功!");
                lb_bookinfo.Content = "";
                if (string.IsNullOrEmpty(tb_sellidsearch.Text))
                {
                    MyOperation.MessageShow("请先输入图书编号");
                    tb_sellidsearch.Focus();
                    return;
                }
                sql = string.Format("SELECT tb.`name` AS `书名`,tb.press AS `出版社`,tb.price AS `定价`,tb.ISBN AS ISBN,st.`name` AS `收书人`," +
                                    "se.`issold` AS `出售`,se.`price` AS `售价` FROM tt_bookinfo AS tb , tt_sellinfo AS se ,tt_staffinfo AS st WHERE tb.id = se.bookid " +
                                    " AND st.staffid = se.buyer AND se.sellinfoid = {0}", sellinfoid);
                DataTable dt = dbo.Selectinfo(sql);
                if (dt.Rows.Count == 1)
                {
                    lb_bookinfo.Content  = "图书唯一ID:" + sellinfoid;
                    lb_bookinfo.Content += "\r\n书名:" + dt.Rows[0]["书名"].ToString();
                    lb_bookinfo.Content += "\r\n出版社:" + dt.Rows[0]["出版社"].ToString();
                    lb_bookinfo.Content += "\r\n定价:" + dt.Rows[0]["定价"].ToString();
                    lb_bookinfo.Content += "\r\n售价:" + dt.Rows[0]["售价"].ToString();
                    lb_bookinfo.Content += "\r\n收书人:" + dt.Rows[0]["收书人"].ToString();
                    lb_bookinfo.Content += "\r\n是否出售:" + ((dt.Rows[0]["出售"].ToString() == "0") ? "否" : "是");
                }
                else
                {
                    tb_sellidsearch.Focus();
                    return;
                }
            }
            else
            {
                MyOperation.MessageShow("修改失败!");
                return;
            }

            //同步修改喵校园主库中的售价信息
            backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
            //backgroundWorker1.RunWorkerCompleted += backgroundWorker1_RunWorkerCompleted;
            backgroundWorker1.DoWork += backgroundWorker1_DoWork;
            string paras = tb_sellidsearch.Text + "|" + tb_price.Text;

            backgroundWorker1.RunWorkerAsync(paras);
        }