Example #1
0
        private void btnList_Click(object sender, EventArgs e)
        {
            FormListCustomer frm = new FormListCustomer();

            frm.Show();
            this.Close();
        }
Example #2
0
        private void Save(Customer obj)
        {
            Db         db            = new Db();
            SqlCommand insertCommand = new SqlCommand("insert Customer(Name,CPF,Cell_Phone,Address,Address_Number,Observation) values(@name,@cpf,@cellphone,@address,@addressnumber,@observation)");

            insertCommand.Parameters.AddWithValue("@name", obj.Name);
            insertCommand.Parameters.AddWithValue("@cpf", obj.CPF);
            insertCommand.Parameters.AddWithValue("@cellphone", obj.Cell_Phone);
            insertCommand.Parameters.AddWithValue("@address", obj.Address);
            insertCommand.Parameters.AddWithValue("@addressnumber", obj.Address_Number);
            insertCommand.Parameters.AddWithValue("@observation", obj.Observation);

            int row = db.executeQuery(insertCommand);

            if (row == 1)
            {
                MessageBox.Show("Cliente cadastrado com sucesso", "Cadastro concluído", MessageBoxButtons.OK, MessageBoxIcon.Information);
                FormListCustomer frm = new FormListCustomer();
            }
            else
            {
                MessageBox.Show("Falha no cadastro, tente novamente", "Falha no cadastro", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Close();
        }