private void Delete_Click(object sender, EventArgs e)
        {
            Button b = sender as Button;

            int projId = int.Parse(b.Name.Replace("DeleteProjById_", string.Empty));

            ObjProjectsEdit.delete(projId);

            buildTable();
        }
        private void buildTable()
        {
            Table.SuspendLayout();

            Table.Controls.Clear();

            List <ObjProjectsEdit> list = ObjProjectsEdit.getList(this.role.Item2);

            Utils.fillRow(Table, new Control[] {
                new Label()
                {
                    Text = "Предмет", AutoSize = true
                },
                new Label()
                {
                    Text = "Задание", AutoSize = true
                },
                new Label()
                {
                    Text = "Описание", AutoSize = true
                },
                new Label()
                {
                    Text = "Срок сдачи", AutoSize = true
                },
                new Label()
                {
                    Text = "Этап 1\nсрок сдачи", AutoSize = true
                },
                new Label()
                {
                    Text = "Этап 2\nсрок сдачи", AutoSize = true
                },
                new Label()
                {
                    Text = "Этап 3\nсрок сдачи", AutoSize = true
                },
                new Label()
                {
                    Text = "Этап 4\nсрок сдачи", AutoSize = true
                },
                new Label()
                {
                    Text = "Этап 5\nсрок сдачи", AutoSize = true
                },
                new Label()
                {
                    Text = "Этап 6\nсрок сдачи", AutoSize = true
                },
                new Label()
                {
                    Text = " "
                },
                new Label()
                {
                    Text = " "
                }
            }, 0);;

            for (int i = 0; i < list.Count; i++)
            {
                ObjProjectsEdit obj = list[i];

                Button edit = Utils.buildButton("Редактировать", $"EditProjById_{obj.id}");
                edit.Width  = 100;
                edit.Click += Edit_Click;

                Button delete = Utils.buildButton("Удалить", $"DeleteProjById_{obj.id}");
                delete.Width  = 100;
                delete.Click += Delete_Click;

                Utils.fillRow(
                    Table,
                    new Control[] {
                    Utils.buildLabel(obj.discipline),
                    Utils.buildLabel(obj.name),
                    Utils.buildLabel(obj.descr),
                    Utils.buildLabel(obj.deadline),
                    Utils.buildLabel(obj.deadline1),
                    Utils.buildLabel(obj.deadline2),
                    Utils.buildLabel(obj.deadline3),
                    Utils.buildLabel(obj.deadline4),
                    Utils.buildLabel(obj.deadline5),
                    Utils.buildLabel(obj.deadline6),
                    edit,
                    delete
                },
                    i + 1
                    );
            }

            Table.ResumeLayout();
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(ProjName.Text))
            {
                MessageBox.Show("Проверьте правильность данных");

                return;
            }

            string name  = ProjName.Text;
            string descr = Description.Text;

            DateTime date         = Calendar.Value;
            bool     ignore       = IgnoreCalendar.Checked;
            string   preparedDate = $"CAST('{date:yyyyMMdd}' as date)";

            DateTime date1 = dateTimePicker1.Value;
            DateTime date2 = dateTimePicker2.Value;
            DateTime date3 = dateTimePicker3.Value;
            DateTime date4 = dateTimePicker4.Value;
            DateTime date5 = dateTimePicker5.Value;
            DateTime date6 = dateTimePicker6.Value;

            bool ignore1 = checkBox1.Checked;
            bool ignore2 = checkBox2.Checked;
            bool ignore3 = checkBox3.Checked;
            bool ignore4 = checkBox4.Checked;
            bool ignore5 = checkBox5.Checked;
            bool ignore6 = checkBox6.Checked;

            string preparedDate1 = $"CAST('{date1:yyyyMMdd}' as date)";
            string preparedDate2 = $"CAST('{date2:yyyyMMdd}' as date)";
            string preparedDate3 = $"CAST('{date3:yyyyMMdd}' as date)";
            string preparedDate4 = $"CAST('{date4:yyyyMMdd}' as date)";
            string preparedDate5 = $"CAST('{date5:yyyyMMdd}' as date)";
            string preparedDate6 = $"CAST('{date6:yyyyMMdd}' as date)";

            Guid guid = Guid.NewGuid();

            ObjProjectsEdit obj = new ObjProjectsEdit()
            {
                id        = this.projId,
                name      = name,
                descr     = descr,
                deadline  = ignore ? "null" : preparedDate,
                deadline1 = ignore1 ? "null" : preparedDate1,
                deadline2 = ignore2 ? "null" : preparedDate2,
                deadline3 = ignore3 ? "null" : preparedDate3,
                deadline4 = ignore4 ? "null" : preparedDate4,
                deadline5 = ignore5 ? "null" : preparedDate5,
                deadline6 = ignore6 ? "null" : preparedDate6,
                token     = guid.ToString()
            };

            ObjProjectsEdit.update(obj);

            uploadFiles(guid);

            MessageBox.Show("Успешно отредактировано!");

            this.Close();
        }