コード例 #1
0
        private void BtDelete_Click(object sender, EventArgs e)
        {
            string SelectedName = "";

            foreach (DataGridViewRow row in DG_TypesOfOccupations.SelectedRows)
            {
                DataRow Row = ((DataRowView)row.DataBoundItem).Row;
                SelectedName += (string)Row["Fullname"] + ", ";
            }
            if (SelectedName.Length > 2)
            {
                SelectedName = SelectedName.Remove(SelectedName.Length - 2);
            }
            DialogResult dr = MessageBox.Show("Удалить вид занятия - " + SelectedName + "?", "Подтверждение", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (DG_TypesOfOccupations.SelectedRows.Count > 0 && dr == DialogResult.OK)
            {
                MTypesOfOccupations mTypesOfOccupations;
                foreach (DataGridViewRow row in DG_TypesOfOccupations.SelectedRows)
                {
                    DataRow Row = ((DataRowView)row.DataBoundItem).Row;
                    mTypesOfOccupations = new MTypesOfOccupations((string)Row["Fullname"], (string)Row["Shortname"]);
                    Program.refData.CTypesOfOccupations.Delete(mTypesOfOccupations);
                }
            }
        }
コード例 #2
0
 private void BtCreateAndClose_Click(object sender, EventArgs e)
 {
     if (String.IsNullOrWhiteSpace(tbFullName.Text) || String.IsNullOrWhiteSpace(tbShortName.Text))
     {
         MessageBox.Show("Заполните все поля");
     }
     else
     {
         MTypesOfOccupations mTypesOfOccupations = new MTypesOfOccupations(tbFullName.Text, tbShortName.Text);
         try
         {
             if (!itsupdate)
             {
                 Program.refData.CTypesOfOccupations.Insert(mTypesOfOccupations);
             }
             else
             {
                 Program.refData.CTypesOfOccupations.Update(mTypesOfOccupations);
             }
             Close();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message);
         }
     }
 }
コード例 #3
0
 public AddTypesOfOccupation(MTypesOfOccupations mTypesOfOccupations)
 {
     InitializeComponent();
     Text = "Изменение вида занятия";
     btCreateAndClean.Visible = false;
     btCreateAndClose.Text    = "Сохранить";
     tbFullName.Text          = mTypesOfOccupations.FullName;
     tbFullName.Enabled       = false;
     tbShortName.Text         = mTypesOfOccupations.ShortName;
     itsupdate = true;
 }
コード例 #4
0
 public void Task_997_2()
 {
     try
     {
         MTypesOfOccupations T = new MTypesOfOccupations("Лекция", "л");
         Assert.AreEqual(typeof(String), T.ShortName.GetType(), "Ожидался тип поля String");
     }
     catch (Exception ex)
     {
         Assert.Fail(ex.Message);
     }
 }
コード例 #5
0
        public void ICTypesOfOccupations_1() //пустая таблица
        {
            //arrange
            bool expected = true;
            //act
            MTypesOfOccupations tp = new MTypesOfOccupations("Лекция", "Л");
            CTypesOfOccupations ct = new CTypesOfOccupations();
            bool actual            = ct.Insert(tp);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #6
0
        public void Task_877_2() //Удаление не существующей строки
        {
            //arrange
            MTypesOfOccupations tp = new MTypesOfOccupations("Лекция", "Л");
            bool expected          = false;
            //act
            CTypesOfOccupations ct = new CTypesOfOccupations();
            bool actual            = ct.Delete(tp);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #7
0
        public void UCTypesOfOccupation_4()
        {
            MTypesOfOccupations t  = new MTypesOfOccupations("Лекция", "л");
            MTypesOfOccupations t1 = new MTypesOfOccupations("Лекция", "л");
            CTypesOfOccupations T  = new CTypesOfOccupations();

            T.Insert(t);
            T.Insert(t1);
            bool expected = true;
            bool actual   = T.Update(t1);

            Assert.AreEqual(expected, actual);
        }
コード例 #8
0
        public AddTypesOfOccupation(MTypesOfOccupations mTypesOfOccupations)
        {
            InitializeComponent();

            tbFullName.Text    = mTypesOfOccupations.FullName;
            tbFullName.Enabled = false;

            tbShortName.Text = mTypesOfOccupations.ShortName;


            this.Text = "Изменение группы";
            type      = mTypesOfOccupations;
        }
コード例 #9
0
        private bool Add()
        {
            string errors = "";
            ushort fullname, shortname;

            if (ushort.TryParse(tbFullName.Text, out fullname) && fullname > 0)
            {
                if (ushort.TryParse(tbShortName.Text, out shortname) && shortname <= fullname && shortname > 0)

                {
                    if (type == null)
                    {
                        MTypesOfOccupations Type = new MTypesOfOccupations(tbFullName.Text, tbShortName.Text);
                        if (Controllers.CTypesOfOccupations.Insert(Type))
                        {
                            return(true);
                        }
                        else
                        {
                            errors = "Невозможно добавить этот вид занятия";
                        }
                    }
                    else
                    {
                        type.FullName  = tbFullName.Text;
                        type.ShortName = tbShortName.Text;
                        if (Controllers.CTypesOfOccupations.Update(type))
                        {
                            return(true);
                        }
                        else
                        {
                            errors = "Невозможно так изменить этот вид занятия";
                        }
                    }
                }
                else
                {
                    errors = "Введите правильный полный вид занятия!";
                }
            }
            else
            {
                errors = "Введите правильный краткий вид занятия!";
            }
            if (errors != "")
            {
                MessageBox.Show(errors, "Попробуйте еще раз");
            }
            return(false);
        }
コード例 #10
0
        public void ICTypesOfOccupations_5() // Ввод корректных данных в таблицу, при условии, что в новой записи все атрибуты повторяют атрибуты записей, содержащихся в таблице
        {
            //arrange
            MTypesOfOccupations tp = new MTypesOfOccupations("Лекция", "Л");
            CTypesOfOccupations ct = new CTypesOfOccupations();
            bool t        = ct.Insert(tp);
            bool expected = false;
            //act
            MTypesOfOccupations tp1 = new MTypesOfOccupations("Лекция", "Л");
            bool actual             = ct.Insert(tp1);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #11
0
        public void ICTypesOfOccupations_3() //Ввод корректных данных, при условии, что краткое название вида занятия дублирует краткое название уже существующего вида занятия
        {
            //arrange
            MTypesOfOccupations tp = new MTypesOfOccupations("Лекция", "Л");
            CTypesOfOccupations ct = new CTypesOfOccupations();
            bool t        = ct.Insert(tp);
            bool expected = true;
            //act
            MTypesOfOccupations tp1 = new MTypesOfOccupations("Лабораторная ", "Л");
            bool actual             = ct.Insert(tp1);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #12
0
        public void ICTypesOfOccupations_2() //Ввод корректных данных, при условии, что полное название вида занятия совпадает с полным названием уже существующего вида занятия
        {
            //arrange
            MTypesOfOccupations tp = new MTypesOfOccupations("Лекция", "Л");
            CTypesOfOccupations ct = new CTypesOfOccupations();
            bool t        = ct.Insert(tp);
            bool expected = false;
            //act
            MTypesOfOccupations tp1 = new MTypesOfOccupations("Лекция", "Лаб");
            bool actual             = ct.Insert(tp1);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #13
0
        public void DCTypesOfOccupation_1() //Удаление существующей строки
        {
            //arrange
            MTypesOfOccupations tp = new MTypesOfOccupations("Лекция", "Л");
            bool expected          = true;
            //act
            CTypesOfOccupations ct = new CTypesOfOccupations();

            ct.Insert(tp);
            bool actual = ct.Delete(tp);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #14
0
        public void Task_873_4() //Ввод корректных данных в таблицу, при условии, что в новой записи ни один атрибут не повторяет атрибуты записей, содержащихся в таблице
        {
            //arrange
            MTypesOfOccupations tp = new MTypesOfOccupations("Лекция", "Л");
            CTypesOfOccupations ct = new CTypesOfOccupations();
            bool t        = ct.Insert(tp);
            bool expected = true;
            //act
            MTypesOfOccupations tp1 = new MTypesOfOccupations("Лабораторная ", "Лаб");
            bool actual             = ct.Insert(tp1);

            //assert
            Assert.AreEqual(expected, actual);
        }
コード例 #15
0
 private void BtChange_Click(object sender, EventArgs e)
 {
     if (DG_TypesOfOccupations.SelectedRows.Count == 1)
     {
         DataRow              Row = ((DataRowView)DG_TypesOfOccupations.SelectedRows[0].DataBoundItem).Row;
         MTypesOfOccupations  mTypesOfOccupations = new MTypesOfOccupations((string)Row["Fullname"], (string)Row["Shortname"]);
         AddTypesOfOccupation add = new AddTypesOfOccupation(mTypesOfOccupations)
         {
             Owner = this
         };
         add.ShowDialog();
     }
     else
     {
         MessageBox.Show("Для изменения выделите только одну строку!");
     }
 }