Beispiel #1
0
        public static Boolean updateSupplier(SupplierDTO supDTO)
        {
            int result;

            try
            {
                string query = "update supplier SET name=@name, address=@address,mobile=@mobile where supplierid=@supplierid";

                MySqlCommand command = new MySqlCommand(query, connection);
                command.Parameters.AddWithValue("@name", supDTO.getName());
                command.Parameters.AddWithValue("@address", supDTO.getAddress());
                command.Parameters.AddWithValue("@mobile", supDTO.getMobile());
                command.Parameters.AddWithValue("@supplierid", supDTO.getSupplierid());

                connection.Open();

                result = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                connection.Close();
                //MessageBox.Show("Error : " + ex.ToString());
                return(false);
            }

            Console.Read();
            connection.Close();
            if (result > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
0
        public static Boolean addSupplier(SupplierDTO supplierDTO)
        {
            int result = 0;

            try
            {
                string       query   = "insert into supplier (supplierid,name,address,mobile) values (@supplierid,@name,@address,@mobile)";
                MySqlCommand command = new MySqlCommand(query, connection);
                command.Parameters.AddWithValue("@supplierid", supplierDTO.getSupplierid());
                command.Parameters.AddWithValue("@name", supplierDTO.getName());
                command.Parameters.AddWithValue("@address", supplierDTO.getAddress());
                command.Parameters.AddWithValue("@mobile", supplierDTO.getMobile());

                connection.Open();
                result = command.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error : " + ex.ToString());
                connection.Close();
                // MessageBox.Show("Error : " + ex.ToString());
                return(false);
            }

            Console.Read();
            connection.Close();

            if (result == 1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }