コード例 #1
0
        void InsertRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblTasviyeHeasb  tblTasviyeHeasb = new tblTasviyeHeasb();

                tblTasviyeHeasb.PazireshID = frmPaziresh.tblPaziresh.PazireshID;

                tblTasviyeHeasb.TarikhTasviyeHeasb = txtTarikhTasviyeHeasb_.MaskedTextProvider.ToDisplayString();

                tblTasviyeHeasb.Mablagh = Convert.ToInt64(txtMablagh_.Text.Replace(",", ""));

                db.tblTasviyeHeasbs.Add(tblTasviyeHeasb);

                db.SaveChanges();

                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #2
0
ファイル: Note.xaml.cs プロジェクト: pashchuk/Hospital-app
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(cardNote.Text))
            {
                MessageBox.Show("Text of note is empty");
                return;
            }
            var context = HospitalEntities.GetEntity();

            switch (_state)
            {
            case Card.WindowState.Create:
                context.notes.Add(new HospitalLibrary.Note()
                {
                    CardID   = _card.CardID,
                    Date     = DateTime.Now,
                    IsHidden = false,
                    NoteText = cardNote.Text,
                    UserID   = _userId
                });
                break;

            case Card.WindowState.Modify:
                _note.NoteText = cardNote.Text;
                _note.Date     = DateTime.Now;
                break;
            }
            context.SaveChanges();
            this.Close();
        }
コード例 #3
0
        public void AddPegawai()
        {
            PegawaiController pc = new PegawaiController();
            int count1 = (pc.ShowData().Count()) + 1;

            using (HospitalEntities context = new HospitalEntities())
            {
                int result = (int)(context.GetNewPegawaiId().FirstOrDefault());
                if (result > -1)
                {
                    Pegawai p = new Pegawai()
                    {
                        ID_Pegawai = result,
                        Jenis_Pegawai = "Dokter",
                        Nama_Pegawai = "Ipir",
                        Alamat_Pegawai = "Keputih",
                        Telp_Pegawai = 0912,
                        Kota = "asd",
                        Email = "asdfs"
                    };
                    //PegawaiController pac = new PegawaiController();
                    pc.AddPegawi(p);
                }

                int count2 = pc.ShowData().Count();

                Assert.AreEqual(count1, count2, "Wrong");

            }
        }
コード例 #4
0
        void BindGrid()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                var Query           = from a in db.tblUsers
                                      select new { a.UserID, a.Name, a.LastName, a.UserName, ActiveName = a.Active == 0 ? "غیرفعال" : "فعال" };

                if (txtSearch.Text.Trim().Length != 0)
                {
                    Query = Query.Where(a => a.UserID.ToString().Contains(txtSearch.Text) || a.Name.Contains(txtSearch.Text) || a.LastName.Contains(txtSearch.Text) || a.UserName.Contains(txtSearch.Text) || a.ActiveName.Contains(txtSearch.Text));
                }

                dgv.DataSource = Query.ToList();

                dgv.Columns[0].HeaderText = "کد کاربری";
                dgv.Columns[0].Width      = 100;
                dgv.Columns[1].HeaderText = "نام";
                dgv.Columns[1].Width      = 100;
                dgv.Columns[2].HeaderText = "نام خانوادگی";
                dgv.Columns[2].Width      = 100;
                dgv.Columns[3].HeaderText = "نام کاربری";
                dgv.Columns[3].Width      = 120;
                dgv.Columns[4].HeaderText = "وضعیت";
                dgv.Columns[4].Width      = 100;
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #5
0
ファイル: Card.xaml.cs プロジェクト: pashchuk/Hospital-app
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            if (string.IsNullOrEmpty(cardName.Text))
            {
                MessageBox.Show("Card name is empty");
                return;
            }
            if (string.IsNullOrEmpty(cardAge.Text))
            {
                MessageBox.Show("Card age is empty");
                return;
            }
            if (cardSex.SelectedItem == null)
            {
                MessageBox.Show("Card sex is empty");
                return;
            }
            if (cardAgain.SelectedItem == null)
            {
                MessageBox.Show("Card isagain is empty");
                return;
            }
            var entity = HospitalEntities.GetEntity();

            switch (_state)
            {
            case WindowState.Create:
                try
                {
                    entity.cards.Add(new HospitalLibrary.Card()
                    {
                        Name       = cardName.Text,
                        PatientAge = int.Parse(cardAge.Text),
                        PatientSex = cardSex.Text,
                        IsAgain    = cardAgain.Text == "New",
                        NoteText   = cardNote.Text
                    });
                }
                catch (FormatException ex)
                {
                    MessageBox.Show("Incorrect format");
                    return;
                }
                break;

            case WindowState.Modify:
                var card = entity.cards.Find(_modifyCardID);
                card.Name       = cardName.Text;
                card.PatientAge = int.Parse(cardAge.Text);
                card.PatientSex = cardSex.Text;
                card.IsAgain    = cardAgain.Text == "New";
                card.NoteText   = cardNote.Text;
                break;

            default:
                break;
            }
            entity.SaveChanges();
            this.Close();
        }
コード例 #6
0
        void BindGrid()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                var Query           = from a in db.tblOtaghs
                                      join b in db.tblBakhshes
                                      on a.BakshID equals b.BakshID
                                      select new { a.OtaghID, a.CodeOtagh, b.BakhshName };


                if (txtSearch.Text.Trim().Length != 0)
                {
                    Query = Query.Where(a => a.OtaghID.ToString().Contains(txtSearch.Text) || a.CodeOtagh.Contains(txtSearch.Text) || a.BakhshName.Contains(txtSearch.Text));
                }

                dgv.DataSource = Query.ToList();

                dgv.Columns[0].HeaderText = "کد اتاق";
                dgv.Columns[0].Width      = 100;
                dgv.Columns[1].HeaderText = "شماره اتاق";
                dgv.Columns[1].Width      = 100;
                dgv.Columns[2].HeaderText = "بخش";
                dgv.Columns[2].Width      = 100;
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #7
0
        void InsertRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblOtagh = new tblOtagh();

                tblOtagh.CodeOtagh = txtCodeOtagh_.Text;
                tblOtagh.BakshID   = (int)cmbBakhsh_.SelectedValue;

                db.tblOtaghs.Add(tblOtagh);
                db.SaveChanges();

                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #8
0
        void BindRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblTasviyeHeasb = db.tblTasviyeHeasbs.Find(tblTasviyeHeasb.TasviyeHeasbID);
                if (tblTasviyeHeasb == null)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                frmPaziresh.tblPaziresh.PazireshID = tblTasviyeHeasb.PazireshID;

                var QueryBimar = (from a in db.tblPazireshes
                                  where a.PazireshID == frmPaziresh.tblPaziresh.PazireshID
                                  select new { name = a.NameBimar + " " + a.LastNameBimar }).ToList();

                txtBimarName.Text           = QueryBimar.ElementAt(0).name;
                txtTarikhTasviyeHeasb_.Text = tblTasviyeHeasb.TarikhTasviyeHeasb;
                txtMablagh_.Text            = tblTasviyeHeasb.Mablagh.ToString();
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.ErrNotFound + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #9
0
        public AdminPage()
        {
            //Initialisation de la bdd et remplisage de la liste de medcin
            InitializeComponent();
            myBdd = new HospitalEntities();

            //On rempli la liste avec les donnees initials
            lstMedcinAdmin.DataContext = myBdd.Medcins.ToList();
        }
コード例 #10
0
 public Menu()
 {
     InitializeComponent();
     context = new HospitalEntities();
     //checks if database is seeded and hides button for it.
     if (context.Prescriptions.Count() > 0)
     {
         buttonLoadDatabase.Hide();
     }
 }
コード例 #11
0
        public MedcinPage()
        {
            InitializeComponent();

            //On cree l'instance de la bdd
            myBdd = new HospitalEntities();

            //On remplie la liste avec les Admission qui ont pas de date de conge
            lstAdmissionMedcin.DataContext = (from ad in myBdd.Admissions where ad.Date_du_conge == null select ad).ToList();
        }
コード例 #12
0
        void UpdateRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblUser = db.tblUsers.Find(tblUser.UserID);

                if (tblUser == null)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                var Query = from a in db.tblUsers
                            where a.UserName == txtUserName_.Text && a.UserID != tblUser.UserID
                            select a;

                if (Query.Count() != 0)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrRepeat + "\n" + "نام کاربری تکراری می باشد", "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                tblUser.Name     = txtName_.Text;
                tblUser.LastName = txtLastName_.Text;
                tblUser.UserName = txtUserName_.Text;
                tblUser.PassWord = txtPassWord_.Text;

                db.Entry(tblUser).State = EntityState.Modified;
                //db.Entry(tblPersonnel).Property(x => x).IsModified = true;
                db.Entry(tblUser).Property(x => x.Active).IsModified = false;

                db.SaveChanges();


                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #13
0
        public Admin()
        {
            InitializeComponent();

            context = new HospitalEntities();
            context.Doctors.Load();
            context.Medicines.Load();
            context.Patients.Load();
            context.Rooms.Load();
            context.Prescriptions.Load();
            createHospitalDataTables();
        }
コード例 #14
0
        public User()
        {
            InitializeComponent();

            context = new HospitalEntities();


            context.Doctors.Load();
            context.Medicines.Load();
            context.Patients.Load();
            context.Rooms.Load();
            context.Prescriptions.Load();
        }
コード例 #15
0
        void BindGrid()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                var Query           = from a in db.tblPazireshes
                                      join b in db.tblPezeshks
                                      on a.PezeshkID equals b.PezeshkID
                                      join c in db.tblOtaghs
                                      on a.OtaghID equals c.OtaghID
                                      join d in db.tblBakhshes
                                      on c.OtaghID equals d.BakshID
                                      select new { a.PazireshID, NameBimar = a.NameBimar + " " + a.LastNameBimar, a.CodeMelliBimar, a.TarikhPaziresh, CodeOtagh = d.BakhshName + " - " + c.CodeOtagh, DoctorName = b.Name + " " + b.LastName };

                if (txtSearch.Text.Trim().Length != 0)
                {
                    Query = Query.Where(a => a.PazireshID.ToString().Contains(txtSearch.Text) ||
                                        a.NameBimar.ToString().Contains(txtSearch.Text) ||
                                        a.CodeMelliBimar.ToString().Contains(txtSearch.Text) ||
                                        a.TarikhPaziresh.ToString().Contains(txtSearch.Text) ||
                                        a.CodeOtagh.ToString().Contains(txtSearch.Text) ||
                                        a.DoctorName.ToString().Contains(txtSearch.Text));
                }

                if (chkArshive.Checked != false || LoadTypeID == 1)
                {
                    Query = Query.Where(a => !(from aa in db.tblTasviyeHeasbs select((int?)aa.PazireshID) ?? 0).Contains(a.PazireshID));
                }

                dgv.DataSource = Query.ToList();

                dgv.Columns[0].HeaderText = "کد پذیرش";
                dgv.Columns[0].Width      = 120;
                dgv.Columns[1].HeaderText = "نام بیمار";
                dgv.Columns[1].Width      = 140;
                dgv.Columns[2].HeaderText = "کد ملی بیمار";
                dgv.Columns[2].Width      = 140;
                dgv.Columns[3].HeaderText = "تاریخ پذیرش";
                dgv.Columns[3].Width      = 120;
                dgv.Columns[4].HeaderText = "اتاق";
                dgv.Columns[4].Width      = 120;
                dgv.Columns[5].HeaderText = "نام پزشک";
                dgv.Columns[5].Width      = 120;
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #16
0
        void ChangeStatusRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblUser = db.tblUsers.Find(tblUser.UserID);

                if (tblUser == null)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                if (tblUser.Active == 1)
                {
                    tblUser.Active = 0;
                }
                else
                {
                    tblUser.Active = 1;
                }


                db.tblUsers.Attach(tblUser);

                db.Entry(tblUser).Property(x => x.Active).IsModified = true; // $('#txtGoodsCode').val(),

                db.SaveChanges();

                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #17
0
        public PreposePage()
        {
            InitializeComponent();
            myBdd = new HospitalEntities();

            //On rempli le combo box des assurances dans l'onglet patient
            cmbAssurancePatient.DataContext = myBdd.Assurances.ToList();

            //On rempli le combo box des medcin sur la page admission
            cmbMedecin.DataContext = myBdd.Medcins.ToList();

            //On rempli la liste de departement
            cmbDepartements.DataContext = (from d in myBdd.Departements select d).ToList();

            //On rempli la liste de type de lit
            cmbTypeLit.DataContext = (from t in myBdd.Type_lit select t).ToList();
        }
コード例 #18
0
        void BindCmbPezeshk()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                var Query           = from a in db.tblPezeshks
                                      select new { a.PezeshkID, PezeshkName = a.Name + " " + a.LastName };

                cmbPezeshk_.DataSource    = Query.ToList();
                cmbPezeshk_.DisplayMember = "PezeshkName";
                cmbPezeshk_.ValueMember   = "PezeshkID";
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #19
0
        public BaseController()
        {
            db    = new HospitalEntities();
            model = new ViewModelHome();

            model.Admin        = db.Admin.FirstOrDefault();
            model.Allergies    = db.Allergies.ToList();
            model.Appointments = db.Appointments.ToList();
            model.Departments  = db.Departments.ToList();
            model.Doctors      = db.Doctors.ToList();
            model.Galleries    = db.Gallery.ToList();
            model.Messages     = db.Messages.ToList();
            model.Nurses       = db.Nurses.ToList();
            model.Patients     = db.Patients.ToList();
            model.Setting      = db.Settings.FirstOrDefault();
            model.Vaccines     = db.Vaccines.ToList();
        }
コード例 #20
0
        void BindCmbBakhsh()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                var Query           = from a in db.tblBakhshes
                                      select new { a.BakshID, a.BakhshName };


                cmbBakhsh_.DataSource = Query.ToList();

                cmbBakhsh_.DisplayMember = "BakhshName";
                cmbBakhsh_.ValueMember   = "BakshID";
            }
            catch (Exception ex)
            {
            }
        }
コード例 #21
0
        void UpdateRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblPaziresh = db.tblPazireshes.Find(tblPaziresh.PazireshID);

                if (tblPaziresh == null)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                tblPaziresh.NameBimar      = txtName_.Text;
                tblPaziresh.LastNameBimar  = txtLastName_.Text;
                tblPaziresh.CodeMelliBimar = txtCodeMelli_.Text;
                tblPaziresh.CodeBimeBimar  = txtCodeBime.Text;
                tblPaziresh.PezeshkID      = (int)cmbPezeshk_.SelectedValue;
                tblPaziresh.OtaghID        = (int)cmbOtagh_.SelectedValue;

                db.Entry(tblPaziresh).State = EntityState.Modified;
                //db.Entry(tblPersonnel).Property(x => x).IsModified = true;
                db.Entry(tblPaziresh).Property(x => x.TarikhPaziresh).IsModified = false;

                db.SaveChanges();

                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #22
0
    protected override ValidationResult IsValid(object value,
                                                ValidationContext validationContext)
    {
        string name     = value.ToString();
        var    property = validationContext.ObjectType.GetProperty(_IdPropertyName);

        if (property != null)
        {
            var idValue = property.GetValue(validationContext.ObjectInstance, null);
            var db      = new HospitalEntities();
            var exists  = db.Doctors.Any(d => d.DoctorName == name && d.Id != idValue);
            if (exists)
            {
                return(new ValidationResult("A doctor already exists with that name"));
            }
            return(ValidationResult.Success);
        }
        return(ValidationResult.Success);
    }
コード例 #23
0
        void InsertRow()
        {
            try
            {
                HospitalEntities db      = new HospitalEntities();
                tblUser          tblUser = new tblUser();
                var Query = from a in db.tblUsers
                            where a.UserName == txtUserName_.Text
                            select a.UserName;
                if (Query.Count() > 0)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrRepeat, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                tblUser.Name     = txtName_.Text;
                tblUser.LastName = txtLastName_.Text;

                tblUser.UserName = txtUserName_.Text;
                tblUser.PassWord = txtPassWord_.Text;
                tblUser.Active   = 1;
                db.tblUsers.Add(tblUser);
                db.SaveChanges();


                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #24
0
        void BindCmbOtagh()
        {
            try
            {
                cmbOtagh_.DataSource = null;
                HospitalEntities db = new HospitalEntities();
                int BakshID         = (int)cmbBakhsh_.SelectedValue;
                var Query           = from a in db.tblOtaghs
                                      where a.BakshID == BakshID
                                      select new { a.OtaghID, a.CodeOtagh };

                cmbOtagh_.DataSource    = Query.ToList();
                cmbOtagh_.DisplayMember = "CodeOtagh";
                cmbOtagh_.ValueMember   = "OtaghID";
            }
            catch (Exception ex)
            {
            }
        }
コード例 #25
0
        void BindRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblOtagh = db.tblOtaghs.Find(tblOtagh.OtaghID);
                if (tblOtagh == null)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                txtCodeOtagh_.Text       = tblOtagh.CodeOtagh;
                cmbBakhsh_.SelectedValue = tblOtagh.BakshID;
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.ErrNotFound + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #26
0
        void UpdateRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblTasviyeHeasb = db.tblTasviyeHeasbs.Find(tblTasviyeHeasb.TasviyeHeasbID);

                if (tblTasviyeHeasb == null)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                tblTasviyeHeasb.PazireshID         = frmPaziresh.tblPaziresh.PazireshID;
                tblTasviyeHeasb.TarikhTasviyeHeasb = txtTarikhTasviyeHeasb_.MaskedTextProvider.ToDisplayString();

                tblTasviyeHeasb.Mablagh = Convert.ToInt64(txtMablagh_.Text.Replace(",", ""));

                db.Entry(tblTasviyeHeasb).State = EntityState.Modified;
                //db.Entry(tblPersonnel).Property(x => x).IsModified = true;

                db.SaveChanges();

                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #27
0
        void DeleteRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblOtagh = db.tblOtaghs.Find(tblOtagh.OtaghID);

                db.tblOtaghs.Remove(tblOtagh);
                db.SaveChanges();

                New();
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #28
0
        void UpdateRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                tblOtagh = db.tblOtaghs.Find(tblOtagh.OtaghID);

                if (tblOtagh == null)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                tblOtagh.CodeOtagh = txtCodeOtagh_.Text;
                tblOtagh.BakshID   = (int)cmbBakhsh_.SelectedValue;

                db.tblOtaghs.Attach(tblOtagh);
                db.Entry(tblOtagh).State = EntityState.Modified;

                db.SaveChanges();

                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
コード例 #29
0
 void BindRow()
 {
     try
     {
         HospitalEntities db = new HospitalEntities();
         tblUser = db.tblUsers.Find(tblUser.UserID);
         if (tblUser == null)
         {
             FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
             return;
         }
         txtName_.Text       = tblUser.Name;
         txtLastName_.Text   = tblUser.LastName;
         txtUserName_.Text   = tblUser.UserName;
         txtPassWord_.Text   = tblUser.PassWord;
         txtRePassWord_.Text = tblUser.PassWord;
     }
     catch (Exception ex)
     {
         FarsiMessagbox.Show(ClsMessage.ErrNotFound + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
     }
 }
コード例 #30
0
        void InsertRow()
        {
            try
            {
                HospitalEntities db          = new HospitalEntities();
                tblPaziresh      tblPaziresh = new tblPaziresh();


                tblPaziresh.NameBimar      = txtName_.Text;
                tblPaziresh.LastNameBimar  = txtLastName_.Text;
                tblPaziresh.CodeMelliBimar = txtCodeMelli_.Text;
                tblPaziresh.CodeBimeBimar  = txtCodeBime.Text;
                tblPaziresh.PezeshkID      = (int)cmbPezeshk_.SelectedValue;
                tblPaziresh.OtaghID        = (int)cmbOtagh_.SelectedValue;

                tblPaziresh.TarikhPaziresh = ClsTools.ShamsiDate();

                db.tblPazireshes.Add(tblPaziresh);
                db.SaveChanges();

                New();
            }
            catch (DbEntityValidationException ex)
            {
                var errorMessages    = ex.EntityValidationErrors.SelectMany(x => x.ValidationErrors).Select(x => x.ErrorMessage);
                var fullErrorMessage = string.Join("\n", errorMessages);
                var exceptionMessage = string.Concat(ClsMessage.Error, ex.Message, " The validation errors are: ", fullErrorMessage);
                FarsiMessagbox.Show(exceptionMessage, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (DbUpdateException ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }