public ActionResult PatientPrefix(PatientPrefix obj, FormCollection fc)
 {
     try
     {
         obj.Gender = fc["Gender"];
         BL_PatientPrefix db = new BL_PatientPrefix();
         if (db.CheckPatientPrefix(obj.PrefixID, obj.PrefixName))
         {
             if (db.Save(obj))
             {
                 if (obj.PrefixID > 0)
                 {
                     ModelState.Clear();
                     TempData["msg"] = " Prefix Updated Successfully";
                 }
                 else
                 {
                     ModelState.Clear();
                     TempData["msg"] = " Prefix Saved Successfully";
                 }
             }
         }
         else
         {
             TempData["msg"] = " Prefix Already Exist's";
         }
         return(RedirectToAction("PatientPrefix", "PatientPrefix"));
     }
     catch (Exception ex)
     {
         TempData["msg"] = ex.Message;
         return(RedirectToAction("PatientPrefix", "PatientPrefix"));
     }
 }
Esempio n. 2
0
        public bool Save(PatientPrefix obj)
        {
            Connect();
            SqlCommand cmd = new SqlCommand("IUPatientPrefix", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@HospitalID", HospitalID);
            cmd.Parameters.AddWithValue("@LocationID", LocationID);
            if (obj.PrefixID == 0)
            {
                cmd.Parameters.AddWithValue("@PrefixID", 0);
                cmd.Parameters.AddWithValue("@Mode", "Add");
            }
            else
            {
                cmd.Parameters.AddWithValue("@PrefixID", obj.PrefixID);
                cmd.Parameters.AddWithValue("@Mode", "Edit");
            }
            cmd.Parameters.AddWithValue("@PrefixName", obj.PrefixName);
            cmd.Parameters.AddWithValue("@Gender", obj.Gender);
            cmd.Parameters.AddWithValue("@CreationID", UserID);
            con.Open();
            int i = cmd.ExecuteNonQuery();

            con.Close();
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        public int DeletePatientPrefix(int PrefixID)
        {
            Connect();
            int           delete = 0;
            PatientPrefix search = new PatientPrefix();
            SqlCommand    cmd    = new SqlCommand("DeletePatientPrefix", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@HospitalID", HospitalID);
            cmd.Parameters.AddWithValue("@LocationID", LocationID);
            cmd.Parameters.AddWithValue("@PrefixID", PrefixID);
            con.Open();
            delete = cmd.ExecuteNonQuery();

            return(delete);
        }
Esempio n. 4
0
        public PatientPrefix GetPrefix(int PrefixID)
        {
            Connect();
            PatientPrefix prefix = new PatientPrefix();

            SqlCommand cmd = new SqlCommand("GetPrefixName", con);

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@PrefixID", PrefixID));
            SqlDataAdapter sd = new SqlDataAdapter(cmd);
            DataTable      dt = new DataTable();

            con.Open();
            sd.Fill(dt);
            con.Close();
            foreach (DataRow dr in dt.Rows)
            {
                prefix.PrefixID   = Convert.ToInt32(dr["PrefixID"]);
                prefix.PrefixName = Convert.ToString(dr["PrefixName"]);
            }

            return(prefix);
        }