示例#1
0
        private void saveHousingGridData_Click(object sender, EventArgs e)
        {
            if (!checkHousingData())
            {
                return;
            }

            Housing housing = new Housing();

            housing.SaveHouses(dataGridView1.Rows);

            AdminPanel_Reload();
        }
示例#2
0
        private void AdminPanel_Load(object sender, EventArgs e)
        {
            Housing   housing = new Housing();
            DataTable table   = housing.GetHousings();

            for (int i = 0; i < table.Rows.Count; i++)
            {
                DataGridViewLinkCell linkCell = new DataGridViewLinkCell();
                linkCell.Value = "Delete";
                dataGridView1.Rows.Add();
                dataGridView1.Rows[i].Cells[0].Value = table.Rows[i][0].ToString();
                dataGridView1.Rows[i].Cells[1].Value = table.Rows[i][1].ToString();
                dataGridView1.Rows[i].Cells[2].Value = table.Rows[i][2].ToString();
                dataGridView1.Rows[i].Cells[3]       = linkCell;
            }
        }
示例#3
0
        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            try
            {
                if (e.ColumnIndex == 3)
                {
                    if (MessageBox.Show("Удалить данный корпус?", "Удаление", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        Housing housing = new Housing();

                        int idHousing = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());


                        dataGridView1.Rows.RemoveAt(e.RowIndex);
                        housing.DeleteHouse(idHousing);
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка!", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }