private void button1_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(tb_sellerid.Text)) { MyOperation.MessageShow("请填写完整的书主号"); tb_sellerid.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}'", tb_sellerid.Text); DataTable dt = dbo.Selectinfo(sql); int count = 0; for (int i = 0; i < dt.Rows.Count; i++) { if ("0" == dt.Rows[i]["是否出售"].ToString()) { dt.Rows[i]["是否出售"] = "否"; } else { dt.Rows[i]["是否出售"] = "是"; count++; } } dataGrid.ItemsSource = dt.DefaultView; lb_info.Content = string.Format("共寄售{0}本,已出售{1}本", dt.Rows.Count.ToString(), count.ToString()); }
private void button2_Click(object sender, RoutedEventArgs e) { lb_bookinfo.Content = ""; if (string.IsNullOrEmpty(textBox2.Text)) { MyOperation.MessageShow("请先输入图书编号"); textBox2.Focus(); return; } string 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}'", textBox2.Text); DataTable dt = dbo.Selectinfo(sql); if (dt.Rows.Count == 1) { lb_bookinfo.Content = "图书唯一ID:" + textBox2.Text; 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 { MyOperation.MessageShow(string.Format("没有查到图书唯一ID为【{0}】的交易", textBox2.Text)); textBox2.Focus(); return; } }
private void SearchSellerinfo() { if (string.IsNullOrEmpty(this.tb_selleridsearch.Text)) { MyOperation.MessageShow("请输入查询的书主号"); this.tb_selleridsearch.Focus(); return; } string sql = string.Format("SELECT * FROM tt_sellerinfo WHERE sellerid = '{0}'", tb_selleridsearch.Text); DataTable dt = dbo.Selectinfo(sql); if (dt.Rows.Count != 1) { sellerid = ""; MyOperation.MessageShow("查询失败,请检查书主号是否正确"); this.tb_selleridsearch.Focus(); return; } else { sellerid = dt.Rows[0]["sellerid"].ToString(); tb_jiebie.Text = dt.Rows[0]["grade"].ToString(); tb_mark.Text = dt.Rows[0]["mark"].ToString(); tb_name.Text = dt.Rows[0]["name"].ToString(); tb_tel.Text = dt.Rows[0]["phone"].ToString(); } }
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(""); }
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; } }
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); }
private void SearchSellinfo() { lb_bookinfo.Content = ""; if (string.IsNullOrEmpty(tb_sellidsearch.Text)) { MyOperation.MessageShow("请先输入图书编号"); tb_sellidsearch.Focus(); return; } string 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}", tb_sellidsearch.Text); DataTable dt = dbo.Selectinfo(sql); if (dt.Rows.Count == 1) { sellinfoid = tb_sellidsearch.Text; lb_bookinfo.Content = "图书唯一ID:" + tb_sellidsearch.Text; 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") ? "否" : "是"); sp1.Visibility = Visibility.Visible; } else { sellinfoid = ""; MyOperation.MessageShow(string.Format("没有查到图书唯一ID为【{0}】的交易", tb_sellidsearch.Text)); tb_sellidsearch.Focus(); return; } }
//搜索书主信息按钮 private void button3_Click(object sender, RoutedEventArgs e) { lb_sellername.Content = ""; if (string.IsNullOrEmpty(tb_sellerid.Text)) { MyOperation.MessageShow("请输入书主号"); tb_sellerid.Focus(); return; } string sql = string.Format("SELECT name FROM tt_sellerinfo WHERE sellerid = '{0}'", tb_sellerid.Text); DataTable dt = dbo.Selectinfo(sql); if (dt.Rows.Count == 1) { lb_sellername.Content = dt.Rows[0]["name"].ToString(); tb_sellinfoid.Text = get_bookid(tb_sellerid.Text); } else { MyOperation.MessageShow("书主号错误"); tb_sellerid.Focus(); return; } }
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("添加失败,请重试"); } }
private void button2_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(textBox2.Text)) { MyOperation.MessageShow("请输入要查询的书主ID"); textBox2.Focus(); return; } displayye(textBox2.Text); }
private void search_book() { lbb_author.Content = lbb_ISBN.Content = lbb_name.Content = lbb_press.Content = lbb_price.Content = ""; if (string.IsNullOrEmpty(tb_isbn.Text)) { MyOperation.MessageShow("请输入图书的ISBN号"); tb_isbn.Focus(); return; } string sql = string.Format("SELECT * FROM tt_bookinfo WHERE isbn LIKE '%{0}%'", tb_isbn.Text); DataTable dt = dbo.Selectinfo(sql); //修改为只看第一个符合ISBN号的图书,这样可以规避ISBN号重复的问题 if (dt.Rows.Count >= 1) { bookinfo boi = new bookinfo(); boi.bookid = dt.Rows[0]["id"].ToString(); boi.author = dt.Rows[0]["author"].ToString(); boi.isbn = dt.Rows[0]["isbn"].ToString(); boi.name = dt.Rows[0]["name"].ToString(); boi.press = dt.Rows[0]["press"].ToString(); boi.price = dt.Rows[0]["price"].ToString(); boi.imgpath = dt.Rows[0]["imgpath"].ToString(); tb_price.Text = (MyOperation.string2float(dt.Rows[0]["price"].ToString()) * 0.3).ToString("0.0"); DisplayBookinfo(boi); return; } //else if (dt.Rows.Count > 1) //{ // MyOperation.MessageShow("存在2本以上相同ISBN号的图书,请确认ISBN号或者联系系统管理员"); // tb_isbn.Focus(); // return; //} else { string url = string.Format("http://api.jige.olege.com/book?q={0}&type=ISBN", tb_isbn.Text); string html = GetHtml(url); bookinfo bi; if (PraseHtml(html, out bi)) { bi.bookid = InsertNewBookInfo(bi); if ("" == bi.bookid) { return; } DisplayBookinfo(bi); } } }
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)); }
private void button2_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(this.textBox1.Text)) { MyOperation.MessageShow("请输入查询的书主信息"); this.textBox1.Focus(); return; } string sql = string.Format("SELECT * FROM tt_sellerinfo WHERE phone LIKE '%{0}%'", textBox1.Text); DataTable dt = dbo.Selectinfo(sql); dataGrid.ItemsSource = dt.DefaultView; }
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, "现金详情表"); }
//按时间导出取现信息 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, "取现详情表"); }
private void tb_isbn_KeyDown(object sender, KeyEventArgs e) { try { if (e.Key == Key.Enter) { search_book(); e.Handled = true; } } catch (Exception e1) { MyOperation.MessageShow(e1.Message); } }
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("系统异常,请联系管理员处理"); } }
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); } }
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, "工时详情表"); }
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("添加失败,请重试"); } }
//出售信息详情表 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, "出售详情表"); }
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("修改失败!"); } }
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("结账成功,可以下班了!"); } }
private void displayye(string sellerid) { string sellername = ""; string sql = string.Format("SELECT `name` FROM tt_sellerinfo WHERE sellerid = '{0}'", sellerid); DataTable dt = dbo.Selectinfo(sql); if (dt.Rows.Count == 0) { MyOperation.MessageShow("查询书主【{0}】信息出错"); return; } else { sellername = dt.Rows[0]["name"].ToString(); } string ye = get_seller_count(sellerid); textBox3.Text = ye; lb_fanance.Content = sellername + ":" + ye; }
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)); }
private void button1_Click(object sender, RoutedEventArgs e) { if (string.IsNullOrEmpty(textBox1.Text)) { MyOperation.MessageShow("请输入要查询的书主ID"); textBox1.Focus(); return; } string sql = string.Format("SELECT ts.`name` AS `name`,tt.count AS count,tt.date AS date FROM tt_sellerinfo " + "AS ts ,tt_tikuan AS tt WHERE ts.sellerid = tt.sellerid AND ts.sellerid = '{0}'", textBox1.Text); DataTable dt = dbo.Selectinfo(sql); if (dt.Rows.Count == 0) { MyOperation.MessageShow("没有查询到书主【{0}】的提款信息"); return; } else { dataGrid.ItemsSource = dt.DefaultView; } }
private string get_bookid(string selleid) { string sql = string.Format("SELECT COUNT(id) FROM tt_sellinfo WHERE sellerid = '{0}'", selleid); DataTable dt = dbo.Selectinfo(sql); int count = int.Parse(dt.Rows[0][0].ToString()) + 1; if (count < 10) { return(selleid + "00" + count.ToString()); } else if (count < 100) { return(selleid + "0" + count.ToString()); } else if (count < 1000) { return(selleid + count.ToString()); } else { MyOperation.MessageShow("用户寄售数字已经超过999,请工作人员处理"); } return(""); }
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"); } }
//添加出售信息按钮 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(); }
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; } }