示例#1
0
        private void button3_Click(object sender, EventArgs e)
        {// add new product button
            Product PD = new Product();
            if (PD.ShowDialog() == DialogResult.OK)
            {
                MySQLConnector.Product P = new MySQLConnector.Product();
                P.P_Code = PD.P_Code;
                P.P_Discription = PD.P_Discription;
                P.P_Price = PD.P_Price;


                if (DB.ProductAdd(P) == MySQLConnector.Result.Success)
                {
                    refreshList();
                }

            }
            else { MessageBox.Show(PD.DialogResult.ToString()); }
        }
        private void listView1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            Product PD = new Product();

            MySQLConnector.Product P = DB.ProductGetByID(int.Parse(listView1.SelectedItems[0].Text));
            PD.P_Code        = P.P_Code;
            PD.P_Discription = P.P_Discription;
            PD.P_Price       = P.P_Price;


            if (PD.ShowDialog() == DialogResult.OK)
            {
                P.P_Code        = PD.P_Code;
                P.P_Discription = PD.P_Discription;
                P.P_Price       = PD.P_Price;

                if (DB.ProductUpdate(P) == MySQLConnector.Result.Success)
                {
                    refreshList();
                }
            }
        }