Exemple #1
0
        public void AddOfficer(Officer newOfficer)
        {
            DataRow row = this.NewRow();
            row[0] = newOfficer.ID;

            foreach (Data.Item item in Data.DataOfficer.Common)
                if (this.Columns.Contains(item.Name))
                    row[this.Columns[item.Name]] = Data.DataOfficer.GetData(newOfficer, item.Name);

            this.Rows.Add(row);
        }
Exemple #2
0
        private void AddOfficer(String name, String surname, String patr, String rank)
        {
            Officer newOf = new Officer();

            newOf.Name = name;
            newOf.Surname = surname;
            newOf.Patronymic = patr;
            newOf.MilRank = rank;

            myContext.Officers.InsertOnSubmit(newOf);
            myContext.SubmitChanges();
        }
Exemple #3
0
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < dataGridViewNew.RowCount - 1; i++)
            {
                if (!RowIsEmpty(dataGridViewNew.Rows[i]))
                {
                    switch (_tableType)
                    {
                        case SampleType.Patients:
                            Patient newPatient = new Patient();
                            //Data.DataPatient dataPatient = new Data.DataPatient();

                            newPatient.MedCard = new MedCard();
                            //newPatient.MedAccount = new MedAccount();
                            newPatient.MilitaryCard = new MilitaryCard();
                            newPatient.PsyCard = new PsyCard();
                            newPatient.StudyCard = new StudyCard();
                            newPatient.WorkCard = new WorkCard();
                            newPatient.BehaviorCard = new BehaviorCard();
                            newPatient.FamilyCard = new FamilyCard();

                            foreach (DataGridView gridTable in tables)
                            {
                                if (!RowIsEmpty(gridTable.Rows[i]))
                                {
                                    _table = (DataTable)gridTable.DataSource;
                                    for (int j = 0; j < _table.Columns.Count; j++)
                                        Data.DataPatient.SetData(_table.Rows[i][_table.Columns[j].ColumnName], _table.Columns[j].ColumnName, ref newPatient);
                                }
                            }

                            int shipID = 0;
                            if (int.TryParse(dataGridViewMil[2, i].Value.ToString(), out shipID))
                            {
                                var ships = from ship in FormMain.myContext.Ships
                                            where ship.BoardNum == shipID
                                            select ship;
                                newPatient.MilitaryCard.Ship = ships.Single();
                            }

                            newPatient.MedCard.Illnesses.AddRange(_illnesses[i]);
                            newPatient.BehaviorCard.PoliceEvents.AddRange(_events[i]);
                            newPatient.Relatives.AddRange(_relatives[i]);

                            FormMain.myContext.Patients.InsertOnSubmit(newPatient);

                            break;

                        case SampleType.Ships:
                            Ship newShip = new Ship();

                            _table = (DataTable)dataGridViewNew.DataSource;
                            for (int j = 0; j < _table.Columns.Count; j++)
                                Data.DataShip.SetData(_table.Rows[i][_table.Columns[j].ColumnName], _table.Columns[j].ColumnName, ref newShip);

                            if (dataGridViewNew[2, i].Value.ToString() != "" && dataGridViewNew[3, i].Value.ToString() != "")
                            {
                                var officers = from officer in FormMain.myContext.Officers
                                            where officer.Surname == dataGridViewNew[2, i].Value.ToString() && officer.Name == dataGridViewNew[3, i].Value.ToString()
                                            select officer;
                                newShip.Officer = officers.Single();
                            }

                            FormMain.myContext.Ships.InsertOnSubmit(newShip);

                            break;

                        case SampleType.Officers:
                            Officer newOfficer = new Officer();

                            _table = (DataTable)dataGridViewNew.DataSource;
                            for (int j = 0; j < _table.Columns.Count; j++)
                                Data.DataOfficer.SetData(_table.Rows[i][_table.Columns[j].ColumnName], _table.Columns[j].ColumnName, ref newOfficer);

                            FormMain.myContext.Officers.InsertOnSubmit(newOfficer);

                            break;
                    }
                }
            }

            FormMain.myContext.SubmitChanges();
        }
Exemple #4
0
 partial void DeleteOfficer(Officer instance);
Exemple #5
0
 partial void UpdateOfficer(Officer instance);
Exemple #6
0
 partial void InsertOfficer(Officer instance);