c# - 在 c# 中使用触发器将产品添加到表购物车(它不会自动关闭)
问题描述
当我尝试在我的 pos 表单中输入数量以添加到表购物车时,它在我输入它们后不会接受或关闭接受值。数量应该在列出所有详细信息的购物车表中更新,但是当我在扫描条形码时在弹出窗口中输入数量后没有任何反应我需要你们的支持人员...
`using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
namespace POSsystem
{
public partial class frmQty : Form
{
//code to connect sql database
SqlConnection cn = new SqlConnection();
SqlCommand cm = new SqlCommand();
DBConnection dbcon = new DBConnection();
SqlDataReader dr;
private String pcode;
private double price;
private string transno;
string stitle = "Simple POS System";
frmPOS fpos;
public frmQty(frmPOS frmpos)
{
InitializeComponent();
cn = new SqlConnection(dbcon.MyConnection());
fpos = frmpos;
}
private void frmQty_Load(object sender, EventArgs e)
{
}
public void ProductDetails(String pcode, double price, String transno)
{
this.pcode = pcode;
this.price = price;
this.transno = transno;
}
private void frmQty_KeyPress(object sender, KeyPressEventArgs e)
{
if ((e.KeyChar == 13) && (txtQty.Text != String.Empty))
{
cn.Open();
cm = new SqlCommand("insert into tblcart (transno, pcode, price, qty,
sdate)values(@transno, @pcode, @price, @qty, @sdate", cn);
cm.Parameters.AddWithValue("@transno", transno);
cm.Parameters.AddWithValue("@pcode", pcode);
cm.Parameters.AddWithValue("@price", price);
cm.Parameters.AddWithValue("@qty", int.Parse(txtQty.Text));
cm.Parameters.AddWithValue("@sdate", DateTime.Now);
cm.ExecuteNonQuery();
fpos.txtSearch.Clear();
fpos.txtSearch.Focus();
this.Dispose();
}
}
}
}
`
解决方案
推荐阅读
- wpf - 将 WPF 项目作为 WinForm 解决方案中的进程进行调试
- python - Tkinter:如何让按钮触发以影响另一个按钮
- pandas - 如何合并数据框中的列值?
- sql-server - 使用十进制数据类型的输入字符串格式不正确
- google-maps - 如何在 Flutter 中为 Google Maps Marker 添加动画?
- orbeon - orbeon 表单 - 动态下拉删除值
- dropbox-api - 无法从 Dropbox 获取令牌
- ios - 无法将颜色设置为分段控制
- css - Vue js Custom 指令在 chrome 中使父宽度小于子宽度,但在 safari 中它给了我相同的
- javascript - 尝试执行 putObject 时出现“配置中缺少凭据,如果使用 AWS_CONFIG_FILE,请设置 AWS_SDK_LOAD_CONFIG=1”错误