首页 > 解决方案 > 在 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();
        }
    }
}
}
`

标签: c#

解决方案


推荐阅读