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);
            }
        }
Beispiel #2
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);
            }
        }
Beispiel #3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ClsTools.CheckValidation(pnlNewEdit) == false)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotRegEmptyValue, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }

                if (txtPassWord_.Text != txtRePassWord_.Text)
                {
                    FarsiMessagbox.Show("تکرار کلمه عبور با کلمه عبور  یکسان نمی باشد", "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }
                if (SaveType == 1)
                {
                    InsertRow();
                }
                else
                {
                    UpdateRow();
                }
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
        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);
            }
        }
Beispiel #5
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);
            }
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                if (ClsTools.CheckValidation(pnlNewEdit) == false || frmPaziresh.tblPaziresh.PazireshID == 0)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotRegEmptyValue, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }


                if (SaveType == 1)
                {
                    InsertRow();
                }
                else
                {
                    UpdateRow();
                }
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
Beispiel #7
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);
            }
        }
Beispiel #8
0
 private void frmUsers_Load(object sender, EventArgs e)
 {
     try
     {
         New();
     }
     catch (Exception ex)
     {
         FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
     }
 }
Beispiel #9
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);
            }
        }
Beispiel #10
0
 private void frmMain_Load(object sender, EventArgs e)
 {
     try
     {
         timeNotif = 0;
         //lblday.Text = WepApi.ClsTools.AyamHafte();
         lblUserName.Text = " خوش آمدید " + Program.tblUserLogin.Name + " " + Program.tblUserLogin.LastName;
     }
     catch (Exception ex)
     {
         FarsiMessagbox.Show(ex.Message, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
     }
 }
Beispiel #11
0
 private void btnDelete_Click(object sender, EventArgs e)
 {
     try
     {
         if (FarsiMessagbox.Show("آیا از حذف اطلاعات مورد نظر مطمئن هستید؟", "حذف", FMessageBoxButtons.YesNo, FMessageBoxIcon.Question) == DialogResult.Yes)
         {
             DeleteRow();
         }
     }
     catch (Exception ex)
     {
         FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
     }
 }
Beispiel #12
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);
            }
        }
Beispiel #13
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);
            }
        }
Beispiel #14
0
 private void btnSelect_Click(object sender, EventArgs e)
 {
     try
     {
         if (tblPaziresh.PazireshID == 0)
         {
             FarsiMessagbox.Show(ClsMessage.Error + "\n" + "رکوردی انتخاب نشده است", "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
             return;
         }
         SaveType   = 1;
         LoadTypeID = 0;
         this.Close();
     }
     catch (Exception)
     {
     }
 }
Beispiel #15
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);
            }
        }
Beispiel #16
0
        private void btnVorud_Click(object sender, EventArgs e)
        {
            try
            {
                //    FrmMain FrmMain = new FrmMain();
                //    FrmMain.ShowDialog();

                if (txtUserName.Text.Trim().Length == 0 || txtPassword.Text.Trim().Length == 0)
                {
                    FarsiMessagbox.Show("تمامی اطلاعات درخواستی را وارد نمایید", "ورود کاربر", FMessageBoxButtons.Ok, FMessageBoxIcon.Information);
                }
                else
                {
                    HospitalEntities db = new HospitalEntities();

                    string password = "";
                    LogContent           = "UserName = "******"نام کاربری یا کلمه عبور اشتباه می باشد.", "ورود کاربر", FMessageBoxButtons.Ok, FMessageBoxIcon.Information);

                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
Beispiel #17
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);
            }
        }
Beispiel #18
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);
            }
        }
Beispiel #19
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);
            }
        }
Beispiel #20
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);
            }
        }
Beispiel #21
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);
            }
        }
Beispiel #22
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);
            }
        }
Beispiel #23
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);
     }
 }
Beispiel #24
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);
            }
        }
Beispiel #25
0
        void BindRow()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();

                var Query = from a in db.tblPazireshes
                            join b in db.tblOtaghs
                            on a.OtaghID equals b.OtaghID
                            where a.PazireshID == tblPaziresh.PazireshID
                            select new { a, b.BakshID };

                if (Query == null)
                {
                    FarsiMessagbox.Show(ClsMessage.ErrNotFound, "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
                    return;
                }
                tblPaziresh.NameBimar      = Query.ToList().ElementAt(0).a.NameBimar;
                tblPaziresh.LastNameBimar  = Query.ToList().ElementAt(0).a.LastNameBimar;
                tblPaziresh.CodeMelliBimar = Query.ToList().ElementAt(0).a.CodeMelliBimar;
                tblPaziresh.CodeBimeBimar  = Query.ToList().ElementAt(0).a.CodeBimeBimar;
                tblPaziresh.PezeshkID      = Query.ToList().ElementAt(0).a.PezeshkID;
                tblPaziresh.OtaghID        = Query.ToList().ElementAt(0).a.OtaghID;

                txtName_.Text             = tblPaziresh.NameBimar;
                txtLastName_.Text         = tblPaziresh.LastNameBimar;
                txtCodeMelli_.Text        = tblPaziresh.CodeMelliBimar.ToString();
                txtCodeBime.Text          = tblPaziresh.CodeBimeBimar;
                cmbPezeshk_.SelectedValue = tblPaziresh.PezeshkID;
                cmbBakhsh_.SelectedValue  = Query.ToList().ElementAt(0).BakshID;

                cmbOtagh_.SelectedValue = tblPaziresh.OtaghID;
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.ErrNotFound + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
Beispiel #26
0
        private void frmPaziresh_Load(object sender, EventArgs e)
        {
            try
            {
                New();
                if (LoadTypeID == 1)
                {
                    btnSelect.Visible  = true;
                    chkArshive.Enabled = false;
                }
                else
                {
                    chkArshive.Enabled = true;
                }

                BindCmbPezeshk();
                BindCmbBakhsh();
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }
Beispiel #27
0
        void BindGrid()
        {
            try
            {
                HospitalEntities db = new HospitalEntities();
                var Query           = from a in db.tblTasviyeHeasbs
                                      join b in db.tblPazireshes on a.PazireshID equals b.PazireshID
                                      select new
                {
                    a.TasviyeHeasbID,
                    NameBimar = b.NameBimar + " " + b.LastNameBimar,
                    a.Mablagh,
                    a.TarikhTasviyeHeasb
                };

                if (txtSearch.Text.Trim().Length != 0)
                {
                    Query = Query.Where(a => a.TasviyeHeasbID.ToString().Contains(txtSearch.Text) || a.NameBimar.ToString().Contains(txtSearch.Text) ||
                                        a.Mablagh.ToString().Contains(txtSearch.Text) || a.TarikhTasviyeHeasb.ToString().Contains(txtSearch.Text));
                }

                dgv.DataSource = Query.ToList();

                dgv.Columns[0].HeaderText = "کد تسویه حساب";
                dgv.Columns[0].Width      = 120;
                dgv.Columns[1].HeaderText = "نام بیمار";
                dgv.Columns[1].Width      = 120;
                dgv.Columns[2].HeaderText = "مبلغ";
                dgv.Columns[2].Width      = 120;
                dgv.Columns[3].HeaderText = "تاریخ تسویه حساب";
                dgv.Columns[3].Width      = 140;
            }
            catch (Exception ex)
            {
                FarsiMessagbox.Show(ClsMessage.Error + "\n" + ex.Message.ToString(), "خطا", FMessageBoxButtons.Ok, FMessageBoxIcon.Error);
            }
        }