Beispiel #1
0
        public void populateDataGridview(MySqlCommand command)
        {
            // change the datagridview row height
            dataGridView1.RowTemplate.Height = 40;

            // populate the datagridview
            CrudOperation func = new CrudOperation();

            dataGridView1.DataSource = func.getData(command);

            // display properties count
            labelCount.Text = "[ " + func.getData(command).Rows.Count + " ] Properties";

            // clear the selection form the datagridview
            dataGridView1.ClearSelection();
        }
        private void btnlogin_Click(object sender, EventArgs e)
        {
            string username = txtUsername.Text;
            string password = txtPassword.Text;

            //  CrudOperation myObj = new CrudOperation();
            Classes.CrudOperation myobj = new CrudOperation();


            if (checkFields())
            {
                MySqlCommand command = new MySqlCommand("SELECT * FROM `users` WHERE `username`=@un AND password=@pass");
                command.Parameters.Add("@un", MySqlDbType.VarChar).Value   = username;
                command.Parameters.Add("@pass", MySqlDbType.VarChar).Value = password;
                DataTable table = myobj.getData(command);

                if (table.Rows.Count > 0)
                {
                    this.DialogResult = DialogResult.OK;
                }
                else
                {
                    lblinvaliddetails.Visible = true;
                    Authenticated             = false;
                }
            }
        }
        // get all properties


        // get property by id
        public DataTable getPropertyById(int id)
        {
            MySqlCommand command = new MySqlCommand("SELECT * FROM `the_property` WHERE `id`=@id");

            command.Parameters.Add("@id", MySqlDbType.Int32).Value = id;
            return(func.getData(command));
        }
        // create a function to populate the datagridview
        public void populateDatagridview(DataGridView dgv, string query)
        {
            MySqlCommand command = new MySqlCommand(query);

            dgv.DataSource = func.getData(command);
        }
        // get all types
        public DataTable getAllTypes()
        {
            MySqlCommand command = new MySqlCommand("SELECT * FROM `property_type`");

            return(func.getData(command));
        }
        // get all sales
        public DataTable getSales()
        {
            MySqlCommand command = new MySqlCommand("SELECT `id`, `property_id` as 'Property', `selling_price` as 'Price', `sale_date` as 'Date' FROM `sale`");

            return(func.getData(command));
        }