private void submit_btn_Click(object sender, EventArgs e) { if (CheckString.CheckISBN(isbn_textbox.Text.Trim()) && CheckString.CheckUDouble(price_textbox.Text.Trim())) { Connector.ChangePrice(isbn_textbox.Text.Trim(), price_textbox.Text.Trim()); dataGridView1.DataSource = Connector.SelectBookInfoTable(0, "").Tables[0].DefaultView; } else if (!CheckString.CheckISBN(isbn_textbox.Text.Trim())) { MessageBox.Show("请检查ISBN填写是否正确", "ISBN格式错误"); } else if (!CheckString.CheckUDouble(price_textbox.Text.Trim())) { MessageBox.Show("请检查价格填写是否正确", "价格错误"); } }
private void submit_btn_Click(object sender, EventArgs e) { if (CheckString.CheckISBN(isbn_textbox.Text.Trim()) && CheckString.CheckUDouble(money_textbox.Text.Trim()) && double.Parse(money_textbox.Text.Trim()) > 0) { String ISBN = isbn_textbox.Text.Trim(); String bookname = bookname_textbox.Text.Trim(); String authorname = author_textbox.Text.Trim(); String publishname = publish_textbok.Text.Trim(); String classificationname = classification_textbox.Text.Trim(); double money = double.Parse(money_textbox.Text.Trim()); String remarks = remarks_textbox.Text.Trim(); MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("确定?", "确认", messButton); if (dr == DialogResult.OK)//如果点击“确定”按钮 { Connector.AddNewBooks(ISBN, bookname, authorname, publishname, classificationname, money, remarks); } else//如果点击“取消”按钮 { isbn_textbox.Text = bookname_textbox.Text = author_textbox.Text = publish_textbok.Text = money_textbox.Text = classification_textbox.Text = remarks_textbox.Text = ""; } } else if (!CheckString.CheckISBN(isbn_textbox.Text.Trim())) { MessageBox.Show("请检查ISBN填写是否正确", "ISBN格式错误"); } else if (!CheckString.CheckUDouble(money_textbox.Text.Trim()) || double.Parse(money_textbox.Text.Trim()) == 0) { MessageBox.Show("请检查价格填写是否正确", "价格填写错误"); } }
private void SubmitSell(object sender, EventArgs e) { if (!CheckString.CheckISBN(isbn_textbox.Text.Trim())) { MessageBox.Show("请检查ISBN填写是否正确", "ISBN格式错误"); } else if (!CheckString.CheckUInt(num_textbox.Text.Trim()) || int.Parse(num_textbox.Text.Trim()) == 0) { MessageBox.Show("请检查数量填写是否正确", "数量错误"); } else { money_textbox.Text = (double.Parse(Connector.GetPrice(isbn_textbox.Text.Trim())) * int.Parse(num_textbox.Text.Trim())).ToString(); String ISBN = isbn_textbox.Text.Trim(); int num = int.Parse(num_textbox.Text.Trim()); String TranMode = mode_textbox.Text.Trim(); String Remarks = remarks_textbox.Text.Trim(); Int64 VipNum; String time; double money = Double.Parse(money_textbox.Text.Trim()); bool flag = true; if (Object.Equals(vipnum_textbox.Text.Trim(), "")) { vipnum_textbox.Text = "0"; VipNum = 0; } else { if (!CheckString.CheckUInt(vipnum_textbox.Text.Trim())) { MessageBox.Show("会员编号填写错误", "会员编号错误"); VipNum = 0; flag = false; } else { VipNum = Int64.Parse(vipnum_textbox.Text.Trim()); } } if (Object.Equals(time_textbox.Text.Trim(), "")) { time_textbox.Text = string.Format("{0:G}", DateTime.Now); time = string.Format("{0:G}", System.DateTime.Now); } else { if (!CheckString.CheckDate(time_textbox.Text.Trim())) { MessageBox.Show("交易时间填写错误", "时间格式错误"); flag = false; time = string.Format("{0:G}", System.DateTime.Now); } else { time = time_textbox.Text.Trim(); } } if (flag) { trannum_textbox.Text = SecurityUnit.EncryptToMD5(VipNum + ISBN + time + TranMode); String TranNum = trannum_textbox.Text.Trim(); MessageBoxButtons messButton = MessageBoxButtons.OKCancel; DialogResult dr = MessageBox.Show("确定?", "确认订单", messButton); if (dr == DialogResult.OK)//如果点击“确定”按钮 { if (Connector.InquireBookNumbers(ISBN) >= num) { Connector.AddToSellList(VipNum, ISBN, time, num, money, TranMode, TranNum, Remarks); Connector.Replenishment(2, ISBN, -1 * num); money_textbox.Text = ""; isbn_textbox.Text = ""; num_textbox.Text = ""; mode_textbox.Text = ""; remarks_textbox.Text = ""; trannum_textbox.Text = ""; time_textbox.Text = ""; vipnum_textbox.Text = ""; if (money > 50 && VipNum == 0) { MessageBoxButtons messButton2 = MessageBoxButtons.OKCancel; DialogResult dr2 = MessageBox.Show("添加会员吗?", "添加会员", messButton2); if (dr2 == DialogResult.OK)//如果点击“确定”按钮 { VipManage newpage = new VipManage(); newpage.Show(); } } } else { MessageBox.Show("存货不足!"); } } else//如果点击“取消”按钮 { vipnum_textbox.Text = isbn_textbox.Text = time_textbox.Text = num_textbox.Text = money_textbox.Text = mode_textbox.Text = remarks_textbox.Text = trannum_textbox.Text = ""; } } } }