• 1405/03/24

تمرین ازاد :

سلام استاد من تو قسمت های 60 و اینا که بودم برا تمرین یه پروژه مدریت باشگاه زدم و همجنین با کمک AI  . دانش خودم ابزاری درست کردم که PATH  لوکال پروژه رو بدم و کل کدای پروژه رو با تقسیم بندی بده که راحت تر با شما به اشتراک بزارم و الان این کدا با اون ابرازه 


# PROJECT CODEBASE EXPORT
# Date: 6/14/2026 11:35:50 PM
# Total Included Files: 7
# Total Skipped Files: 5
==================================================

### FILE INDEX (INCLUDED) ###
- \Add.cs
- \chef.cs
- \Form1.cs
- \Person.cs
- \PersonRepository.cs
- \Program.cs
- \Student.cs

### SKIPPED FILES REPORT ###
  Ignored Folder
Add.Designer.cs  ->  Auto-generated designer file
Form1.Designer.cs  ->  Auto-generated designer file
Gym\bin  ->  Ignored Folder
obj  ->  Ignored Folder

==================================================
### BEGIN CODE CONTENT ###



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace Gym
{
    public partial class Add : Form
    {
        public Add()
        {
            InitializeComponent();
        }
        public void UnChecked()
        {
            if (!cbChef.Checked)
            {
                nudSabeghe = null;

            }

            else if (!cbStudent.Checked)
            {
                nudDaysRemaining = null;
                txtChefName.Text = null;


            }


        }
        public void chked()
        {

            if (cbChef.Checked)
            {
                nudSabeghe.Visible = cbChef.Checked;

            }


            else if (cbStudent.Checked)
            {
                nudDaysRemaining.Visible = cbStudent.Checked;
                txtChefName.Visible = cbStudent.Checked;


            }

        }
        public void BtnSave()
        {

            btnSave.Enabled = true;

        }
        private void cbStudent_CheckedChanged(object sender, EventArgs e)
        {
            UnChecked();
            chked();
            BtnSave();

        }

        private void cbChef_CheckedChanged(object sender, EventArgs e)
        {
            UnChecked();
            chked();
            BtnSave();
        }


        private void btnSave_Click(object sender, EventArgs e)
        {
            if (txtChefName.Text!=""||txtChefName.Text!=""||nudSabeghe.Value!=null)
            {
                Person person = new Person() 
                
                {
                   NameAndFamily = TxtName.Text
                
                
                };
                person.Mobile=txtMobile.Text;
                person.CodMeli=txtCodemeli.Text;
                person.Age=((int)nudAge.Value);
                if(cbStudent.Checked)
                {
                    person.Type = "Student";


                }
                if(cbChef.Checked)
                {
                    person.Type = "Chef";

                }
                if(person is Student student)
                {
                    student.DaysRemaining = ((int)nudDaysRemaining.Value);
                    student.ChefName = txtChefName.Text;


                }
                if(person is chef chef)
                {
                    chef.Sabeghe = ((int)nudSabeghe.Value);


                }
                PersionRepository.AddPerson(person);
                this.Close();
            }
        }
    }
}

====== END OF FILE ======


using System;
using System.Collections.Generic;
using System.Text;

namespace Gym
{
    public class chef:Person
    {
        public  int Sabeghe { get; set; }
    }
}

====== END OF FILE ======


namespace Gym
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public void popo()
        {

            dataGridView1.Rows.Clear();

            var data = PersionRepository.GtAllPerson();
            foreach (Person p in data)
            {

                int id = p.Id;
                string name = p.NameAndFamily;
                string codmeli = p.CodMeli;
                string mobile = p.Mobile;
                int age = p.Age;
                string typePerson = p.Type;


                int daysRemaining = 0;
                string chefName = "";
                int sabeghe = 0;


                if (p is Student student)
                {
                    daysRemaining = student.DaysRemaining;
                    chefName = student.ChefName;

                }
                else if (p is chef chief)
                {
                    sabeghe = chief.Sabeghe;

                }


                dataGridView1.Rows.Add(id, name, mobile, age,codmeli, typePerson,
                                       daysRemaining, chefName, sabeghe);
            }
            if (PersionRepository.GetCount() == PersionRepository.PersonCount)
            {
                btnAdd.Enabled = false;


            }

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

        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
       

        private void btnAdd_Click(object sender, EventArgs e)
        {
            Add add = new Add();
            add.ShowDialog();
            popo();
        }
        private void oioi()
        {
            dataGridView1.Rows.Clear();

            btnAdd.Enabled = true;


        }
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            switch (comboBox1.SelectedIndex)
            {
                case 0:
                    {
                        PersionRepository.PersonCount = 5;
                        oioi();
                        break;
                    }
                case 1:
                    {
                        PersionRepository.PersonCount = 15;
                        oioi();
                        break;
                    }
                case 2:
                    {
                        PersionRepository.PersonCount = 80;
                        oioi();
                        break;
                    }
            }
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.SelectedItem = "Vip";
        }
    }
}

====== END OF FILE ======


using System;
using System.Collections.Generic;
using System.Text;

namespace Gym
{
    public class Person
    {
        public int Id { get; set; }
        public string NameAndFamily { get; init; }
        public string Mobile { get; set; }

        public int Age { get; set; }
        public string CodMeli { get; set; }
        public string Type { get; set; }


    }
}

====== END OF FILE ======


using System;
using System.Collections.Generic;
using System.Text;

namespace Gym
{
    public class PersionRepository
    {
        public static int PersonCount = 0;
        private static int _nextid = 1;
        private static List<Person>_person=new List<Person>();




        public static List<Person> GtAllPerson ()
        {
            return  _person;
        }
        public static void AddPerson(Person person)
        {

            _person.Add(person);
           person.Id = _nextid++;
        }
        public static int GetCount()
        {
            return _person.Count;


        }
    }
}

====== END OF FILE ======


namespace Gym
{
    internal static class Program
    {
        /// <summary>
        ///  The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main()
        {
            // To customize application configuration such as set high DPI settings or default font,
            // see https://aka.ms/applicationconfiguration.
            ApplicationConfiguration.Initialize();
            Application.Run(new Form1());
        }
    }
}
====== END OF FILE ======


using System;
using System.Collections.Generic;
using System.Text;

namespace Gym
{
    public class Student :Person
    {
        public int DaysRemaining { get; set; }
        public string ChefName { get; set; }
    }
}

====== END OF FILE ======