Beispiel #1
0
        public void AddShip(Ship newShip)
        {
            DataRow row = this.NewRow();
            row[0] = newShip.ID;

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

            this.Rows.Add(row);
        }
Beispiel #2
0
 partial void DeleteShip(Ship instance);
Beispiel #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();
        }
Beispiel #4
0
 partial void UpdateShip(Ship instance);
Beispiel #5
0
 partial void InsertShip(Ship instance);
Beispiel #6
0
		private void detach_Ships(Ship entity)
		{
			this.SendPropertyChanging();
			entity.Officer = null;
		}
Beispiel #7
0
		private void attach_Ships(Ship entity)
		{
			this.SendPropertyChanging();
			entity.Officer = this;
		}
Beispiel #8
0
        private void AddShip(String name, int num)
        {
            Ship newShip = new Ship();

            newShip.BoardNum = num;
            newShip.Name = name;

            myContext.Ships.InsertOnSubmit(newShip);
            myContext.SubmitChanges();
        }