private void button10_Click(object sender, EventArgs e) { MessageBoxTimeOut _messageBox = new MessageBoxTimeOut(); _messageBox.Show("测试", "警告"); }
//购买确定按钮 private void button2_Click(object sender, EventArgs e) { MessageBoxTimeOut mb = new MessageBoxTimeOut(); Random ran = new Random(); string orderid = DateTime.Now.ToString("yyyyMMddhhmmss") + ran.Next(1000, 9999).ToString(); //自动生成订单号 string paydate = DateTime.Now.ToString("yyyy-MM-dd"); try { using (SqlConnection conn = new SqlConnection(AppConst.DbPath)) { string strsql2 = " "; strsql2 = "insert into order_table([orderID] ,[userID] ,[shopID] ,[orderTotalPrice] ,[shipAddress] ,[payMethod] ,[payDate] ,[tranStatus]) values(@orderID,@userID,@shopID,@orderTotalPrice,@shipAddress,@payMethod,@payDate,@tranStatus)"; using (SqlCommand comm = new SqlCommand { CommandText = strsql2, CommandType = CommandType.Text, Connection = conn }) { comm.Parameters.AddWithValue("@orderID", orderid); comm.Parameters.AddWithValue("@userID", "201801"); comm.Parameters.AddWithValue("@shopID", "1001"); comm.Parameters.AddWithValue("@orderTotalPrice", this.SUM); comm.Parameters.AddWithValue("@shipAddress", "广东省湛江市赤坎区"); comm.Parameters.AddWithValue("@payMethod", 0); comm.Parameters.AddWithValue("@payDate", paydate); comm.Parameters.AddWithValue("@tranStatus", 1); conn.Open(); if (Convert.ToInt32(comm.ExecuteNonQuery()) > 0) { //MessageBox.Show("添加成功"); //DialogResult = DialogResult.OK; } else { MessageBox.Show("添加失败!"); } } } } catch (SqlException sqlex) { MessageBox.Show("数据库连接错误,错误源是" + sqlex.Message); } foreach (var item in WIDS) { try { using (SqlConnection conn = new SqlConnection(AppConst.DbPath)) { using (SqlCommand cmd = new SqlCommand($"delete from [Shopping_Cart] where commID='{item}'", conn)) { conn.Open(); if (Convert.ToInt32(cmd.ExecuteNonQuery()) > 0) { //MessageBox.Show("删除成功"); } else { MessageBox.Show(item); } } } } catch (SqlException sqlex) { MessageBox.Show("数据库连接错误,错误源是" + sqlex.Message); } } mb.Show("支付中.........", "提示"); MessageBox.Show("支付完成", "success"); DialogResult = DialogResult.Cancel; }