我有两种形式,第一种形式有insertdata(),我想提前致电付款表格我该怎么办

问题描述 投票:0回答:1

public void insertdata(){尝试{

            con.Open();
            OleDbCommand cmd = con.CreateCommand();
            cmd.CommandType = CommandType.Text;
            cmd.CommandText = "insert into customers(customer_name,address,email,mob_no) values('" + tname.Text + "','" + taddress.Text + "','" + temail.Text + "','" + tmobno.Text + "')";
            cmd.ExecuteNonQuery();
            MessageBox.Show("Registered Successfully");



            con.Close();
            tname.Text = "";
            taddress.Text = "";
            temail.Text = "";
            tmobno.Text = "";
        }
        catch (Exception e)
        {
            MessageBox.Show("Problem in Registering Customer,Please Enter all Fields Correctly" + e);

        }

    }

''这是我要在另一个窗体上调用的函数,它是button_click上的advancePayment。

c#-4.0
1个回答
0
投票

由于要在多个位置调用同一函数,因此可以创建另一个带有insertdata()函数的类。之后,您可以在各自的表单中添加该类的引用。

© www.soinside.com 2019 - 2024. All rights reserved.