コード例 #1
0
        public ActionResult Create([Bind(Include = "Id,Name,ClientId,Gender,ImagePath")] Patient patient, HttpPostedFileBase file)
        {
            if (ModelState.IsValid && patient.Name != null && patient.Gender != 0)
            {
                var patientBll = new PatientBLL();

                if (file != null && file.ContentLength > 0)
                {
                    string filename = Path.GetFileName(file.FileName);
                    string imgpath  = Path.Combine(Server.MapPath("~/Content/PatientImages/"), filename);
                    file.SaveAs(imgpath);
                    patient.ImgPath = "~/Content/PatientImages/" + file.FileName;
                }
                else
                {
                    patient.ImgPath = "~/Content/PatientImages/default.jpg";
                }

                patientBll.Insert(patient);
                return(RedirectToAction("Index"));
            }
            var clientBll = new ClientBLL();

            ViewBag.ClientId = new SelectList(clientBll.List(), "Id", "FullName", patient.ClientId);
            return(View(patient));
        }
コード例 #2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            DialogResult sure = new DialogResult();

            sure = MessageBox.Show("Kayıt İşleminizi Onaylıyor musunuz?", "", MessageBoxButtons.YesNo);

            if (txtPassword.Text == txtPasswordAgain.Text && txtPassword.TextLength >= 6 && txtPassword.TextLength <= 15)
            {
                if (txtAnswer.Text != "" && cmbSecurityQuest.SelectedIndex > -1)
                {
                    _patient = new Patient();

                    _patient.IdentityNumber = long.Parse(txtIıdentityNO.Text);
                    _patient.FirstName      = txtFirstName.Text;
                    _patient.LastName       = txtLastName.Text;
                    _patient.gender         = Convert.ToString(cmbGender.SelectedItem);
                    _patient.DateOfBirth    = DateTime.Parse(dtpDateOfBirth.Value.ToShortDateString());
                    _patient.PlaceOfBirth   = txtDateOfPlace.Text;
                    _patient.MotherName     = txtMotherName.Text;
                    _patient.FatherName     = txtFatherName.Text;
                    _patient.CellPhone      = mtxtCellPhone.Text;
                    _patient.HomePhone      = mtxtHomePhone.Text;
                    _patient.EMail          = txtEmail.Text;



                    _patient.Password         = txtPassword.Text;
                    _patient.SecurityQuestion = Convert.ToString(cmbSecurityQuest.SelectedItem);
                    _patient.Answer           = txtAnswer.Text;
                    bool result;

                    if (IsSave)
                    {
                        if (sure == DialogResult.Yes)
                        {
                            result = _patientBLL.Insert(_patient);
                            MessageBox.Show("Kayıt İşleminiz Gerçekleşmiştir Giriş Ekranına Yönlendiriliyorsunuz..");

                            LoginForm loginForm = new LoginForm();
                            loginForm.Show();
                            this.Close();
                        }
                    }
                    else
                    {
                        MessageBox.Show("Kayıt İşlemi Başarısız Olmuştur!");
                    }
                }
                else
                {
                    MessageBox.Show("Lütfen Gerekli Alanları Doldurunuz!");
                }
            }
            else
            {
                MessageBox.Show("Lütfen Parolanızı 6 İle 15 Karakter Uzunluğunda Giriniz!");
            }
        }
コード例 #3
0
        public ActionResult Create([Bind(Include = "Id,ClientId,Name,Gender,Age, Image")] PatientModel patient, HttpPostedFileBase Image)
        {
            try
            {
                if (patient.Name == null || patient.Name == string.Empty)
                {
                    ModelState.AddModelError("Name", "Debe ingresar un nombre");
                }

                if (patient.ClientId == 0)
                {
                    ModelState.AddModelError("ClientId", "Debe seleccionar un cliente");
                }

                if (patient.Age == 0)
                {
                    ModelState.AddModelError("Age", "Debe ingresar una edad");
                }

                IEnumerable <Patient> patients = patientBusiness.GetByFilters(PatientModel.FromModel(patient));

                if (patients.ToList().Count > 0)
                {
                    ModelState.AddModelError("Model", "Ya existe un paciente con nombre: " +
                                             patient.Name + " y dueño: " + patient.ClientId);
                }


                if (ModelState.IsValid)
                {
                    Patient p = patientBusiness.Insert(PatientModel.FromModel(patient));

                    //Guardar imagen en carpeta local
                    if (Image != null)
                    {
                        var fileName    = Path.GetFileName(Image.FileName);
                        var extension   = fileName.Substring(fileName.IndexOf('.'));
                        var newFileName = p.Id + extension;
                        var path        = Path.Combine(Server.MapPath("~/Content/Images"), newFileName);
                        Image.SaveAs(path);
                    }


                    return(RedirectToAction("Index"));
                }

                var clients = patientBusiness.List();
                ViewBag.ClientId = new SelectList(clients, "Id", "Name", patient.ClientId);
                return(View(patient));
            }
            catch (Exception ex)
            {
                Log.Error(ex.Message, ex);
                return(View());
            }
        }