Resolved Windows Forms for organization

weekend33

New member
Joined
Jun 19, 2023
Messages
2
Programming Experience
Beginner
Первое окно
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace kod1._2_var6
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void план_мероприятийBindingNavigatorSaveItem_Click(object sender, EventArgs e)
        {
            this.Validate();
            this.план_мероприятийBindingSource.EndEdit();
            this.tableAdapterManager.UpdateAll(this._sergutin_kod1_2DataSet);

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            // TODO: данная строка кода позволяет загрузить данные в таблицу "_sergutin_kod1_2DataSet.План_мероприятий". При необходимости она может быть перемещена или удалена.
            this.план_мероприятийTableAdapter.Fill(this._sergutin_kod1_2DataSet.План_мероприятий);

        }

        private void план_мероприятийDataGridView_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
    }
    private void button1_Click(object sender, EventArgs e)
        {
            план_мероприятийBindingSource.Filter = "Событие='" + comboBox1.Text + "'";
        }

        private void button2_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < план_мероприятийDataGridView.ColumnCount - 1; i++)
            {
                for (int j = 0; j < план_мероприятийDataGridView.RowCount - 1; j++)
                {
                    план_мероприятийDataGridView[i, j].Style.BackColor = Color.White; план_мероприятийDataGridView[i, j].Style.ForeColor = Color.Black;
                }
            }
            for (int i = 0; i < план_мероприятийDataGridView.ColumnCount - 1; i++)
            {
                for (int j = 0; j < план_мероприятийDataGridView.RowCount - 1; j++)
                {
                    if (план_мероприятийDataGridView[i, j].Value.ToString().IndexOf(textBox1.Text) != -1)
                    {
                        план_мероприятийDataGridView[i, j].Style.BackColor = Color.AliceBlue; план_мероприятийDataGridView[i, j].Style.ForeColor = Color.Blue;

                    }
                }
            }

        }

        private void button3_Click(object sender, EventArgs e)
        {
            план_мероприятийBindingSource.Filter = "";
        }

        private void button4_Click(object sender, EventArgs e)
        {
            Login newForm = new Login();
            this.Hide();
            newForm.Show();

        }
    }
}
Второе окно
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace kod1._2_var6
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
    }

        private void button2_Click(object sender, EventArgs e)
        {
            Form1 newForm = new Form1();
            this.Hide();
            newForm.Show();
        }

        public static string SetValueForText1 = "";
        public static string SetValueForText2 = "";

        private void button1_Click(object sender, EventArgs e)
        {
        SqlConnection conn = new SqlConnection(@"Data Source=SERVER_BIT\SQLEXPRESS;Initial Catalog=sergutin_kod1.2;User ID=user1;Password=userdb1
");
         
            try
            {
                if (radioButton1.Checked == true)
                {
                    String querry = "SELECT * FROM Участники WHERE Почта = '" + textBox1.Text + "' AND пароль = '" + textBox2.Text + "'";
                    SqlDataAdapter sda = new SqlDataAdapter(querry, conn);
                    DataTable dtable = new DataTable();
                    sda.Fill(dtable);
                    if (dtable.Rows.Count > 0)
                    {
                        Form3 newForm = new Form3();
                        newForm.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid");
                    }
                }
                else if (radioButton2.Checked == true)
                {
                    String querry = "SELECT * FROM Модераторы WHERE почта = '" + textBox1.Text + "' AND пароль = '" + textBox2.Text + "'";
                    SqlDataAdapter sda = new SqlDataAdapter(querry, conn);
                    DataTable dtable = new DataTable();
                    sda.Fill(dtable);
                    if (dtable.Rows.Count > 0)
                    {
                        Form4 newForm = new Form4();
                        newForm.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid");
                    }
                }
                else if (radioButton3.Checked == true)
                {
                    String querry = "SELECT * FROM Жюри WHERE почта = '" + textBox1.Text + "' AND пароль = '" + textBox2.Text + "'";
                    SqlDataAdapter sda = new SqlDataAdapter(querry, conn);
                    DataTable dtable = new DataTable();
                    sda.Fill(dtable);
                    if (dtable.Rows.Count > 0)
                    {
                        Form4 newForm = new Form4();
                        newForm.Show();
                    }
                    else
                    {
                        MessageBox.Show("Invalid");
                    }
                }
                else if (radioButton4.Checked == true)
                {
                    String querry = "SELECT * FROM Организаторы WHERE Почта = '" + textBox1.Text + "' AND пароль = '" + textBox2.Text + "'";
                    SqlDataAdapter sda = new SqlDataAdapter(querry, conn);
                    DataTable dtable = new DataTable();
                    sda.Fill(dtable);
                    if (dtable.Rows.Count > 0)
                    {
                        SetValueForText1 = textBox1.Text;
                        SetValueForText2 = textBox2.Text;
                        Form5 newForm = new Form5();
                        newForm.Show();
                        this.Hide();
                    }
                    else
                    {
                        MessageBox.Show("Invalid");MessageBox.Show("Invalid");
                    }
                }
                else
                {
                    MessageBox.Show("Invalid");
                }
            }
            catch
            {
                MessageBox.Show("Er");
            }
          
        }

        private void checkBox1_CheckedChanged(object sender, EventArgs e)
        {
        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
        }
    }
}
Третье окно
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace kod1._2_var6
{
    public partial class Form3 : Form
    {
        public Form3()
        {
            InitializeComponent();
        }
    }
}
Четвёртое окно
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace kod1._2_var6
{
    public partial class Form4 : Form
    {
        public Form4()
        {
            InitializeComponent();
        }

        private void Form4_Load(object sender, EventArgs e)
        {

        }
    }
}
Пятое окно
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;
using System.Drawing.Drawing2D;

namespace kod1._2_var6
{
    public partial class Form5 : Form
    {
        public Form5()
        {
            InitializeComponent();
        }

        private void Form5_Load(object sender, EventArgs e)
        {
            if (DateTime.Now.Hour < 11)
            {
                label1.Text = "Доброе утро!";
            }
            else if (DateTime.Now.Hour < 18)
            {
                label1.Text = "Добрый день!";
            }
            else
            {
                label1.Text = "Добрый вечер!";
            }

            label2.Text = Login.SetValueForText1;
            label3.Text = Login.SetValueForText2;

            SqlConnection conn = new SqlConnection(@"Data Source=SERVER_BIT\SQLEXPRESS;Initial Catalog=sergutin_kod1.2;User ID=user1;Password=userdb1
");
            String querry = "SELECT * FROM Организаторы WHERE Почта = '" + label2.Text + "' AND пароль = '" + label3.Text + "'";
            SqlDataAdapter sda = new SqlDataAdapter(querry, conn);
            DataTable dtable = new DataTable();
            sda.Fill(dtable);
            if (dtable.Rows.Count > 0)
            {
                object[] data = {dtable.Rows[0][0], dtable.Rows[0][7]};
                label4.Text = data[0].ToString();
                label5.Text = data[1].ToString();

                if (label5.Text == "мужской")
                {
                    label6.Text = "Mr";
                }
                else
                {
                    label6.Text = "Mrs";
                }
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void button3_Click(object sender, EventArgs e)
        {
            Form6 newForm = new Form6();
            newForm.Show();
            this.Hide();
        }
    }
}
Шестое окно
C#:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace kod1._2_var6
{
    public partial class Form6 : Form
    {
        public Form6()
        {
            InitializeComponent();
        }
        private void Form6_Load(object sender, EventArgs e)
        {
            //[EMAIL]tkgduj6na1hm@gmail.com[/EMAIL]
            //JS4K8pr54u
            /*Random rnd = new Random();
            int randomnum = rnd.Next(0, 99999);
            textBox1.Text = randomnum.ToString();
            label1.Text = randomnum.ToString();*/
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            Random rnd = new Random();
            int randomnum = rnd.Next(0, 99999);
            textBox1.Text = randomnum.ToString();
            label1.Text = randomnum.ToString();
        }
    }
}


Please accept this article. I need it to pass the exam, after which I am ready to delete it. I was very grateful, because this will decide the fate of my red diploma.
 
Last edited by a moderator:
Solution
Welcome to the forum. In the future, please put your code in code tags in the future. I'll edit your post later to put it into code tags.

We prefer that you not delete your post after you have received your answer so that others will have a chance to learn as well.

You dumped a whole bunch of code on us, but without a question in English. This is an English language forum. What do you need help with?
Welcome to the forum. In the future, please put your code in code tags in the future. I'll edit your post later to put it into code tags.

We prefer that you not delete your post after you have received your answer so that others will have a chance to learn as well.

You dumped a whole bunch of code on us, but without a question in English. This is an English language forum. What do you need help with?
 
Solution
Congratulations!
 

Latest posts

Back
Top Bottom