Exemplo n.º 1
0
        //private int CaptainComparator(Airplane A, Airplane B)
        //{
        //    if (A.GetCap().Firstname[0] != B.GetCap().Firstname[0])
        //    {
        //        if (Convert.ToSByte(A.GetCap().Firstname[0]) < Convert.ToSByte(B.GetCap().Firstname[0]))
        //            return -1;
        //        else
        //            return 1;

        //    }
        //    else if (A.GetCap().Firstname[0] == B.GetCap().Firstname[0] && A.GetCap().Firstname[1] != B.GetCap().Firstname[1])
        //    {
        //        if (Convert.ToSByte(A.GetCap().Firstname[1]) < Convert.ToSByte(B.GetCap().Firstname[1]))
        //            return -1;
        //        else
        //            return 1;
        //    }
        //    else return 0;
        //}
        //private int PilotComparator(Airplane A, Airplane B)
        //{

        //    if (A.GetPil().Firstname[0] != B.GetPil().Firstname[0])
        //    {
        //        if (Convert.ToSByte(A.GetPil().Firstname[0]) < Convert.ToSByte(B.GetPil().Firstname[0]))
        //            return -1;
        //        else
        //            return 1;

        //    }
        //    else if (A.GetPil().Firstname[0] == B.GetPil().Firstname[0] && A.GetPil().Firstname[1] != B.GetPil().Firstname[1])
        //    {
        //        if (Convert.ToSByte(A.GetPil().Firstname[1]) < Convert.ToSByte(B.GetPil().Firstname[1]))
        //            return -1;
        //        else
        //            return 1;
        //    }
        //    else return 0;
        //}
        //private int LTOComparator(Airplane A, Airplane B)
        //{

        //    if (Convert.ToDateTime(A.LastService) < Convert.ToDateTime(B.LastService))
        //        return 1;

        //    else if (Convert.ToDateTime(A.LastService) > Convert.ToDateTime(B.LastService))
        //        return -1;
        //    else return 0;
        //}
        //#endregion
        /// <summary>
        /// Очистка поля элементов и добавление TextBox для вывода результата
        /// </summary>



        private void button1_Click(object sender, EventArgs e)
        {
            int Idpl = 1;

            foreach (var cell in dataGridView1.SelectedCells)
            {
                Idpl = (int)(cell as DataGridViewTextBoxCell).Value;
            }
            FAddCrewMember nm = new FAddCrewMember(Idpl);

            nm.Show();
        }
Exemplo n.º 2
0
        private void GoToCreateCrewForm_Click(object sender, EventArgs e)
        {
            try
            {
                var results = new List <ValidationResult>();
                var context = new ValidationContext(plane);

                plane.Carrying    = Convert.ToInt32(TBCarrying.Text);
                plane.IssueYear   = Convert.ToInt32(LYIssue.Text);
                plane.LastService = LSmonthCalendar.SelectionStart.ToLongDateString();
                plane.Model       = TBAirplaneModel.Text;
                plane.Places      = Convert.ToInt32(CBNumberOfPlaces.SelectedItem);
                if (RBMilitary.Checked)
                {
                    plane.Type = RBMilitary.Text;
                }
                else if (RBPassenger.Checked)
                {
                    plane.Type = RBPassenger.Text;
                }
                else if (RBTransporter.Checked)
                {
                    plane.Type = RBTransporter.Text;
                }
                else
                {
                    MessageBox.Show("Ошибка в радиобаттонах");
                }
                plane.Id       = Airport.number + 1;
                plane.crewNumb = Convert.ToInt32(TBNumberOfMembers.Text);
                if (!Validator.TryValidateObject(plane, context, results, true))
                {
                    foreach (var res in results)
                    {
                        throw new ValidationException(res.ErrorMessage);
                    }
                }
                FAddCrewMember membersForm = new FAddCrewMember(plane, this);
                membersForm.Show();
            }
            catch (ValidationException ex)
            {
                MessageBox.Show(ex.Message);
            }
            catch (FormatException)
            {
                MessageBox.Show("Empty fields!");
            }
        }
Exemplo n.º 3
0
        private void GoToCreateCrewForm_Click(object sender, EventArgs e)
        {
            using (MyDbContext db = new MyDbContext())
            {
                Airplane ap = new Airplane();
                ap.Issue = _calend.SelectionStart;
                ap.Model = _model.Text;
                if (RBMilitary.Checked)
                {
                    ap.Type = RBMilitary.Text;
                }
                else if (RBPassenger.Checked)
                {
                    ap.Type = RBPassenger.Text;
                }
                else if (RBTransporter.Checked)
                {
                    ap.Type = RBTransporter.Text;
                }
                ap.Places = Convert.ToInt32(_places.Text);
                ap.Pic    = ConvertImageToByteArray(imPath);
                db.Airplanes.Add(ap);
                db.SaveChanges();
                foreach (var plane in db.Airplanes)
                {
                    if (plane.PlaneId >= id1)
                    {
                        apId = plane.PlaneId;
                        id1  = plane.PlaneId;
                    }
                }
            }
            FAddCrewMember cm = new FAddCrewMember(apId);

            cm.Show();
            this.Close();
        }