コード例 #1
0
        public DataTable DeleteCustomer(InfowayCustomer customer)
        {
            DataTable customerTable = new DataTable("Customers");
            int       result        = 0;

            using (MySqlConnection CN = new MySqlConnection(ConfigurationManager.ConnectionStrings["InfowayMySqlConStr"].ConnectionString))
            {
                CN.Open();
                MySqlCommand CMD = new MySqlCommand();
                CMD.Connection  = CN;
                CMD.CommandType = CommandType.StoredProcedure;
                CMD.CommandText = "DeleteInfowayCustomers";
                CMD.Parameters.AddWithValue("p_CustomerId", customer.CustomerId);
                result = CMD.ExecuteNonQuery();
                CN.Close();
            }
            if (result > 0)
            {
                return(GetAllCustomers());
            }
            else
            {
                throw new Exception("Insert Optioration failed! Please retry!");
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: Nikita-0105/190843120042
        private void btnModify_Click(object sender, EventArgs e)
        {
            InfowayCustomer customer = new InfowayCustomer()
            {
                CustomerId  = int.Parse(txtCustomerId.Text),
                ContactName = txtContactName.Text,
                City        = txtCity.Text
            };

            try
            {
                customerDal.UpdateCustomer(customer);
                customersTable = customerDal.GetAllCustomers();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }