Exemplo n.º 1
0
        public static SupplierDTO searchSupplier(String supplierid)
        {
            SupplierDTO supDTO = new SupplierDTO();

            try
            {
                String       query   = "select * from supplier where supplierid=@supplierid;";
                MySqlCommand command = new MySqlCommand(query, connection);
                command.Parameters.AddWithValue("@supplierid", supplierid);
                connection.Open();

                MySqlDataReader dataReader = command.ExecuteReader();
                //int result = command.ExecuteNonQuery();
                //using (SqlDataReader reader = command.ExecuteReader())
                //int count = 0;

                while (dataReader.Read())
                {
                    supDTO.setSupplierid(dataReader["supplierid"].ToString());
                    supDTO.setName(dataReader["name"].ToString());
                    supDTO.setAddress(dataReader["address"].ToString());
                    supDTO.setMobile(dataReader["mobile"].ToString());
                    //Console.WriteLine(dataReader["NIC"] + " " + dataReader["Name"] + " " + dataReader["Address"]);
                    //count++;
                }

                /*if(count==0)
                 *  MessageBox.Show("No relevant data..");*/
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                connection.Close();
                //MessageBox.Show("Error : " + ex.ToString());
                return(null);
            }

            Console.Read();
            connection.Close();
            return(supDTO);
        }
Exemplo n.º 2
0
        private void BtnAddUser_Click(object sender, EventArgs e)
        {
            if (ValidateText())
            {
                SupplierDTO supDTO = new SupplierDTO();
                supDTO.setSupplierid(txtSupplierID.Text);
                supDTO.setName(txtSupplierName.Text);
                supDTO.setMobile(txtSupplierMobile.Text);
                supDTO.setAddress(txtSupplierAddress.Text);

                Boolean result = SupplierController.addSupplier(supDTO);
                if (result)
                {
                    MessageBox.Show("Supplier details added to the database successfully..");
                }
                else
                {
                    MessageBox.Show("Error occured supplier not added..");
                }
                loadTable();
                clear();
            }
        }