Exemplo n.º 1
0
        private void AddButton_Click(object sender, EventArgs e)
        {
            try
            {
                switch (changeTable.SelectedIndex)
                {
                case 0:
                {
                    AddClassroomForm form = new AddClassroomForm(connectionString);
                    form.FormClosed += changeTable_SelectedIndexChanged;
                    form.Show();
                    break;
                }

                case 1:
                {
                    AddFloorForm form = new AddFloorForm(connectionString);
                    form.FormClosed += changeTable_SelectedIndexChanged;
                    form.Show();
                    break;
                }

                case 2:
                {
                    AddFirmForm form = new AddFirmForm(connectionString);
                    form.FormClosed += changeTable_SelectedIndexChanged;
                    form.Show();
                    break;
                }

                case 3:
                {
                    AddPersonForm form = new AddPersonForm(connectionString);
                    form.FormClosed += changeTable_SelectedIndexChanged;
                    form.Show();
                    break;
                }

                case 4:
                {
                    AddActOfRentingForm form = new AddActOfRentingForm(connectionString);
                    form.FormClosed += changeTable_SelectedIndexChanged;
                    form.Show();
                    break;
                }

                default:
                {
                    throw new Exception("Выход за предел выбора таблиц");
                }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 2
0
        private void infoDGV_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            switch (changeTable.SelectedIndex)
            {
            case 0:
            {
                short            number = Convert.ToInt16(infoDGV.Rows[e.RowIndex].Cells[0].Value);
                byte             floor  = Convert.ToByte(infoDGV.Rows[e.RowIndex].Cells[2].Value);
                AddClassroomForm form   = new AddClassroomForm(connectionString, (from c in context.classroom
                                                                                  where c.number == number &&
                                                                                  c.floor_number == floor
                                                                                  select c.id).FirstOrDefault());
                form.FormClosed += changeTable_SelectedIndexChanged;
                form.Show();
                break;
            }

            case 1:
            {
                byte         num  = Convert.ToByte(infoDGV.SelectedRows[0].Cells[0].Value);
                AddFloorForm form = new AddFloorForm(connectionString, num);
                form.FormClosed += changeTable_SelectedIndexChanged;
                form.Show();
                break;
            }

            case 2:
            {
                string      name      = infoDGV.Rows[e.RowIndex].Cells[0].Value.ToString();
                string      phone     = infoDGV.Rows[e.RowIndex].Cells[1].Value.ToString();
                string      contactFN = infoDGV.Rows[e.RowIndex].Cells[2].Value.ToString();
                string      contactLN = infoDGV.Rows[e.RowIndex].Cells[3].Value.ToString();
                string      contactMN = infoDGV.Rows[e.RowIndex].Cells[4].Value.ToString();
                AddFirmForm form      = new AddFirmForm(connectionString, (from f in context.firm
                                                                           where f.name == name &&
                                                                           f.contact_phone_number == phone &&
                                                                           f.contact_first_name == contactFN &&
                                                                           f.contact_last_name == contactLN &&
                                                                           f.contact_middle_name == contactMN
                                                                           select f.id).FirstOrDefault());
                form.FormClosed += changeTable_SelectedIndexChanged;
                form.Show();
                break;
            }

            case 3:
            {
                string        firstName  = infoDGV.Rows[e.RowIndex].Cells[0].Value.ToString();
                string        lastName   = infoDGV.Rows[e.RowIndex].Cells[1].Value.ToString();
                string        middleName = infoDGV.Rows[e.RowIndex].Cells[2].Value.ToString();
                AddPersonForm form       = new AddPersonForm(connectionString, (from p in context.person
                                                                                where p.first_name == firstName &&
                                                                                p.last_name == lastName &&
                                                                                p.middle_name == middleName
                                                                                select p.id).FirstOrDefault());
                form.FormClosed += changeTable_SelectedIndexChanged;
                form.Show();
                break;
            }

            case 4:
            {
                string              firmName    = infoDGV.Rows[e.RowIndex].Cells[0].Value.ToString();
                byte                floorNumber = Convert.ToByte(infoDGV.Rows[e.RowIndex].Cells[1].Value);
                DateTime            startDate   = Convert.ToDateTime(infoDGV.Rows[e.RowIndex].Cells[2].Value);
                DateTime            endDate     = Convert.ToDateTime(infoDGV.Rows[e.RowIndex].Cells[3].Value);
                decimal             sum         = Convert.ToDecimal(infoDGV.Rows[e.RowIndex].Cells[4].Value);
                AddActOfRentingForm form        = new AddActOfRentingForm(connectionString, (from aor in context.act_of_renting
                                                                                             join fr in context.firm on aor.firm_id equals fr.id
                                                                                             where fr.name == firmName &&
                                                                                             aor.floor_number == floorNumber &&
                                                                                             aor.start_date == startDate &&
                                                                                             aor.end_date == endDate &&
                                                                                             aor.sum_of_money == sum
                                                                                             select aor.id).FirstOrDefault());
                form.FormClosed += changeTable_SelectedIndexChanged;
                form.Show();
                break;
            }

            default:
            {
                throw new Exception("Выход за предел выбора таблиц");
            }
            }
        }