Esempio n. 1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            using (var uow = (AdoNetUnitOfWork)UnitOfWorkFactory.Create(UnitOfWorkFactory.ConnectionType.SQL, Connection.connectionString))
            {
                try
                {
                    var dRepos = new DoctorRepository(uow);
                    dRepos.CheckLeave();
                    uow.SaveChanges();
                }
                catch
                {
                }
            }
            using (var uow = (AdoNetUnitOfWork)UnitOfWorkFactory.Create(UnitOfWorkFactory.ConnectionType.SQL, Connection.connectionString))
            {
                try
                {
                    var nRepos = new NurseRepository(uow);
                    nRepos.CheckLeave();
                    uow.SaveChanges();
                }
                catch
                {
                }
            }

            timer1.Enabled = false;
        }
        private void btnDocAdd_Click(object sender, EventArgs e)
        {
            int  data   = 0;
            bool _excep = false;

            using (var uow = (AdoNetUnitOfWork)UnitOfWorkFactory.Create(UnitOfWorkFactory.ConnectionType.SQL, Connection.connectionString))
            {
                var    docRepos = new DoctorRepository(uow);
                Doctor doctor   = new Doctor()
                {
                    IdentityNo  = txtDocIdentityNO.Text,
                    FullName    = txtDocFullName.Text,
                    Phone       = txtDocPhone.Text,
                    Email       = txtDocEmail.Text,
                    Adress      = txtDocAddress.Text,
                    Salary      = Convert.ToDecimal(txtDocSalary.Text),
                    BirthDate   = dateTimePicker2.Value,
                    Unit        = (int)cmbDocUnit.SelectedValue,
                    Polyclinic  = (int)cmbDocPoly.SelectedValue,
                    isAdult     = chkDocAdult.Checked,
                    doOperation = chkDocAdult.Checked
                };
                try
                {
                    data = docRepos.AddDoctor(doctor);
                    uow.SaveChanges();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                    _excep = true;
                }
            }
            if (_excep == false && data == 1)
            {
                MessageBox.Show("The operation is successfull...");
            }
        }
        private void AddUser_Load(object sender, EventArgs e)
        {
            switch (operationName)
            {
            case Enums.CommonOperationType.OUser:
                this.Height            = pnlUser.Height + 300;
                pnlUser.Visible        = true;
                pnlNurse.Visible       = false;
                pnlAddPatient.Visible  = false;
                pnlPolyclinic.Visible  = false;
                pnlAddDoc.Visible      = false;
                pnlAppointment.Visible = false;
                pnlUnit.Visible        = false;
                pnlUser.Left           = (this.Width - pnlUser.Width) / 2;
                pnlUser.Top            = (this.Height - pnlUser.Height) / 2 - 10;
                break;

            case Enums.CommonOperationType.ONurse:
                this.Height            = pnlNurse.Height + 100;
                pnlAppointment.Visible = false;
                pnlUser.Visible        = false;
                pnlNurse.Visible       = true;
                pnlAddPatient.Visible  = false;
                pnlPolyclinic.Visible  = false;
                pnlAddDoc.Visible      = false;
                pnlUnit.Visible        = false;
                pnlNurse.Left          = (this.Width - pnlNurse.Width) / 2;
                pnlNurse.Top           = (this.Height - pnlNurse.Height) / 2 - 10;
                using (var uow = (AdoNetUnitOfWork)UnitOfWorkFactory.Create(UnitOfWorkFactory.ConnectionType.SQL, Connection.connectionString))
                {
                    string[] workTypes = Enum.GetNames(typeof(Enums.NurseWorkType));
                    cmbWorkType.DataSource = workTypes;
                    PolyclinicRepository pRepos = new PolyclinicRepository(uow);
                    UnitRepository       uRepos = new UnitRepository(uow);
                    cmbPolyclinic.DisplayMember = "Name";
                    cmbPolyclinic.ValueMember   = "ID";
                    cmbPolyclinic.DataSource    = pRepos.GetAllPolyclinicsL();
                    cmbPolyclinic.Text          = "Choose A Polyclinic.";
                }
                break;

            case Enums.CommonOperationType.OPatient:
                this.Height            = pnlAddPatient.Height + 100;
                pnlAppointment.Visible = false;
                pnlUser.Visible        = false;
                pnlNurse.Visible       = false;
                pnlAddPatient.Visible  = true;
                pnlPolyclinic.Visible  = false;
                pnlAddDoc.Visible      = false;
                pnlUnit.Visible        = false;
                pnlAddPatient.Left     = (this.Width - pnlAddPatient.Width) / 2;
                pnlAddPatient.Top      = (this.Height - pnlAddPatient.Height) / 2 - 10;
                using (var uow = (AdoNetUnitOfWork)UnitOfWorkFactory.Create(UnitOfWorkFactory.ConnectionType.SQL, Connection.connectionString))
                {
                    cmbBloodType.DataSource      = Enum.GetNames(typeof(Enums.BloodType));
                    cmbSocialSecurity.DataSource = Enum.GetNames(typeof(Enums.SocialSecurity));
                }
                break;

            case Enums.CommonOperationType.OUnit:
                this.Height            = pnlUser.Height + 300;
                pnlAppointment.Visible = false;
                pnlUser.Visible        = false;
                pnlNurse.Visible       = false;
                pnlAddPatient.Visible  = false;
                pnlPolyclinic.Visible  = false;
                pnlAddDoc.Visible      = false;
                pnlUnit.Visible        = true;
                pnlUnit.Left           = (this.Width - pnlUnit.Width) / 2;
                pnlUnit.Top            = (this.Height - pnlUnit.Height) / 2 - 10;
                using (var uow = (AdoNetUnitOfWork)UnitOfWorkFactory.Create(UnitOfWorkFactory.ConnectionType.SQL, Connection.connectionString))
                {
                    var pRepos = new PolyclinicRepository(uow);
                    cmbPoly.DisplayMember = "Name";
                    cmbPoly.ValueMember   = "ID";
                    cmbPoly.DataSource    = pRepos.GetAllPolyclinicsL();
                }
                break;

            case Enums.CommonOperationType.OAppoinment:
                this.Height            = pnlAppointment.Height + 100;
                pnlAppointment.Visible = true;
                pnlUser.Visible        = false;
                pnlNurse.Visible       = false;
                pnlAddPatient.Visible  = false;
                pnlPolyclinic.Visible  = false;
                pnlAddDoc.Visible      = false;
                pnlUnit.Visible        = false;
                pnlAppointment.Left    = (this.Width - pnlAppointment.Width) / 2;
                pnlAppointment.Top     = (this.Height - pnlAppointment.Height) / 2 - 10;
                using (var uow = (AdoNetUnitOfWork)UnitOfWorkFactory.Create(UnitOfWorkFactory.ConnectionType.SQL, Connection.connectionString))
                {
                    var docRepos  = new DoctorRepository(uow);
                    var pRepos    = new PatientRepository(uow);
                    var polyRepos = new PolyclinicRepository(uow);
                    var uRepos    = new UnitRepository(uow);
                    cmbAppDoc.ValueMember       = "ID";
                    cmbAppDoc.DisplayMember     = "FullName";
                    cmbAppDoc.DataSource        = docRepos.GetAllDoctorsForAppointment();
                    cmbAppDoc.Text              = "Choose A Doctor..";
                    cmbAppPoly.ValueMember      = "ID";
                    cmbAppPoly.DisplayMember    = "Name";
                    cmbAppPoly.DataSource       = polyRepos.GetAllPolyclinicsL();
                    cmbAppPoly.Text             = "Choose a Polyclinic...";
                    cmbAppPatient.ValueMember   = "ID";
                    cmbAppPatient.DisplayMember = "FullName";
                    cmbAppPatient.DataSource    = pRepos.GetAllPatientsL();
                    cmbAppPatient.Text          = "Choose a Patient..";
                }
                break;

            case Enums.CommonOperationType.ODoctor:
                this.Height            = pnlAddDoc.Height + 100;
                pnlAppointment.Visible = false;
                pnlUser.Visible        = false;
                pnlNurse.Visible       = false;
                pnlAddPatient.Visible  = false;
                pnlPolyclinic.Visible  = false;
                pnlAddDoc.Visible      = true;
                pnlUnit.Visible        = false;
                pnlAddDoc.Left         = (this.Width - pnlAddDoc.Width) / 2;
                pnlAddDoc.Top          = (this.Height - pnlAddDoc.Height) / 2 - 10;
                using (var uow = (AdoNetUnitOfWork)UnitOfWorkFactory.Create(UnitOfWorkFactory.ConnectionType.SQL, Connection.connectionString))
                {
                    PolyclinicRepository pRepos = new PolyclinicRepository(uow);
                    UnitRepository       uRepos = new UnitRepository(uow);
                    cmbDocPoly.DisplayMember = "Name";
                    cmbDocPoly.ValueMember   = "ID";
                    cmbDocPoly.DataSource    = pRepos.GetAllPolyclinicsL();
                    cmbDocPoly.Text          = "Choose A Polyclinic.";
                }
                break;

            case Enums.CommonOperationType.OPolyclinic:
                this.Height            = pnlPolyclinic.Height + 100;
                pnlAppointment.Visible = false;
                pnlUser.Visible        = false;
                pnlNurse.Visible       = false;
                pnlAddPatient.Visible  = false;
                pnlPolyclinic.Visible  = true;
                pnlAddDoc.Visible      = false;
                pnlUnit.Visible        = false;
                pnlPolyclinic.Left     = (this.Width - pnlPolyclinic.Width) / 2;
                pnlPolyclinic.Top      = (this.Height - pnlPolyclinic.Height) / 2 - 10;
                break;
            }
        }