public ActionResult Edit(PatientInfo model)
        {
            try
            {
                ViewBag.GuardianRelation = new SelectList(Dropdowns.Relation, "Value", "Text", model.GuardianRelation);
                ViewBag.Gender           = new SelectList(Dropdowns.Genders, "Value", "Text", model.Gender);
                if (ModelState.IsValid)
                {
                    obj.Update(model, out outmodel);
                    if (!outmodel.Error)
                    {
                        // TODO: Add update logic here

                        return(RedirectToAction("Index"));
                    }
                    else
                    {
                        return(View(model));
                    }
                }
                else
                {
                    return(View(model));
                }
            }
            catch
            {
                return(View());
            }
        }
 private void buttonX3_Click(object sender, EventArgs e)
 {
     if (getValue(0) == null)
     {
     }
     else
     {
         Patient obj = new Patient();
         obj.Id             = (int)getValue(0);
         obj.Name           = textBoxX6.Text;
         obj.PhoneNo        = textBoxX2.Text;
         obj.Address        = textBoxX5.Text;
         obj.Age            = (int)numericUpDown2.Value;
         obj.Gender         = radioButton4.Checked ? true : false;
         obj.DoctorId       = (int)comboBoxEx1.SelectedValue;
         obj.ReceptionistId = (int)comboBoxEx6.SelectedValue;
         obj.RoomId         = (int)comboBoxEx2.SelectedValue;
         try
         {
             BL.Update(obj);
             refresh();
             textBoxX6.Text       = "";
             textBoxX2.Text       = "";
             textBoxX5.Text       = "";
             numericUpDown2.Value = 0;
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "خطا");
         }
     }
 }