Beispiel #1
0
        private void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            String idObj = "nepoznato";
            String imeObj = "nepoznato";
            String vojnaPosta = "nepoznato";
            String imeGrada = "nepoznato";
            String telefon = "nepoznato";
            String faks = "nepoznato";
            int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
            DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];
            idObj = Convert.ToString(selectedRow.Cells[0].Value);
            imeObj = Convert.ToString(selectedRow.Cells[1].Value);
            vojnaPosta = Convert.ToString(selectedRow.Cells[2].Value);
            imeGrada = Convert.ToString(selectedRow.Cells[3].Value);
            telefon = Convert.ToString(selectedRow.Cells[4].Value);
            faks = Convert.ToString(selectedRow.Cells[5].Value);

            EditObjekta editGrad = new EditObjekta(this, sqlite, idObj, imeObj, vojnaPosta, imeGrada, telefon, faks);
            editGrad.Show();
        }
Beispiel #2
0
        private void buttonEdit_Click(object sender, EventArgs e)
        {
            String idObj = "nepoznato";
            String imeObj = "nepoznato";
            String vojnaPosta = "nepoznato";
            String imeGrada = "nepoznato";
            String telefon = "nepoznato";
            String faks = "nepoznato";
            if (comboBoxObjekti.SelectedIndex == -1)
            {
                if (dataGridView1.SelectedCells.Count > 0)
                {
                    int selectedrowindex = dataGridView1.SelectedCells[0].RowIndex;
                    DataGridViewRow selectedRow = dataGridView1.Rows[selectedrowindex];
                    idObj = Convert.ToString(selectedRow.Cells[0].Value);
                    imeObj = Convert.ToString(selectedRow.Cells[1].Value);
                    vojnaPosta = Convert.ToString(selectedRow.Cells[2].Value);
                    imeGrada = Convert.ToString(selectedRow.Cells[3].Value);
                    telefon = Convert.ToString(selectedRow.Cells[4].Value);
                    faks = Convert.ToString(selectedRow.Cells[5].Value);

                    EditObjekta editGrad = new EditObjekta(this, sqlite, idObj, imeObj, vojnaPosta, imeGrada, telefon, faks);
                    editGrad.Show();
                }
            }
            else
            {
                SQLiteCommand nadjiIObj = sqlite.CreateCommand();
                nadjiIObj.CommandText = "select objekatID, vojnaPosta, gradID, telefon, faks  from OBJEKAT where imeObjekta ='" + comboBoxObjekti.SelectedItem.ToString() + "';";
                SQLiteDataReader dr = nadjiIObj.ExecuteReader();
                dr.Read();
                idObj = Convert.ToString(dr.GetInt32(0));
                imeObj = comboBoxObjekti.SelectedItem.ToString();
                try
                {
                    vojnaPosta = Convert.ToString(dr.GetInt32(1));
                }
                catch { }
                int gradID = dr.GetInt32(2);
                try
                {
                    telefon = dr.GetString(3);
                }
                catch { }
                try
                {
                    faks = dr.GetString(3);
                }
                catch { }
                dr.Close();

                SQLiteCommand nadjiImeGrada = sqlite.CreateCommand();
                nadjiImeGrada.CommandText = "select imeGrada from GRAD where gradID =" + gradID + ";";
                dr = nadjiImeGrada.ExecuteReader();
                dr.Read();
                imeGrada = dr.GetString(0);
                dr.Close();

                EditObjekta editGrad = new EditObjekta(this, sqlite, idObj, imeObj, vojnaPosta, imeGrada, telefon, faks);
                editGrad.Show();
            }
        }