Exemplo n.º 1
0
 private void BtnSupplierUpdate_Click(object sender, EventArgs e)
 {
     if (ValidateText())
     {
         SupplierDTO supDTO = new SupplierDTO(txtSupplierID.Text, txtSupplierName.Text, txtSupplierAddress.Text, txtSupplierMobile.Text);
         Boolean     result = SupplierController.updateSupplier(supDTO);
         if (result)
         {
             MessageBox.Show("Supplier details updated in the database successfully..");
         }
         else
         {
             MessageBox.Show("Error occured supplier details not updated..");
         }
         loadTable();
         clear();
     }
 }
Exemplo n.º 2
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.º 3
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();
            }
        }
Exemplo n.º 4
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);
            }
        }
Exemplo n.º 5
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);
            }
        }