public JsonResult GetPatientCWProfileRate(int id)
        {
            BL_PatientCWProfile _PatientCWProfile = new BL_PatientCWProfile();
            PatientCWProfile    AddServiceMod     = new PatientCWProfile();

            DataSet ds = _PatientCWProfile.GetPatientCWProfileRate(id);


            List <PatientCWProfile> search = new List <PatientCWProfile>();

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                search.Add(new PatientCWProfile
                {
                    ProfileID      = dr["ProfileID"].ToString(),
                    ProfileName    = dr["Name"].ToString(),
                    OrganizationID = Convert.ToInt32(dr["OrganizationID"].ToString()),
                    //  OrganizationName = dr["OrganizationName"].ToString(),
                    PatientCWProfileID = dr["PatientCWProfileID"].ToString(),
                    GeneralCharges     = dr["GeneralCharges"].ToString(),
                    EmergencyCharges   = dr["EmergencyCharges"].ToString(),
                });
            }
            return(new JsonResult {
                Data = search, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public bool Save(PatientCWProfile obj)
        {
            Connect();
            con.Open();
            try
            {
                if (obj.PatientCWProfileID != "0")
                {
                    SqlCommand cmd = new SqlCommand("IUPatientCWProfileRate", con);
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@HospitalID", HospitalID);
                    cmd.Parameters.AddWithValue("@LocationID", LocationID);
                    cmd.Parameters.AddWithValue("@PatientCWProfileID", obj.PatientCWProfileID);
                    cmd.Parameters.AddWithValue("@OrganizationID", obj.OrganizationID);
                    cmd.Parameters.AddWithValue("@ProfileID", obj.ProfileID);
                    cmd.Parameters.AddWithValue("@GeneralCharges", obj.GeneralCharges);
                    cmd.Parameters.AddWithValue("@EmergencyCharges", obj.EmergencyCharges);
                    cmd.Parameters.AddWithValue("@CreationID", UserID);
                    cmd.Parameters.AddWithValue("@RecommendedByDoctor", "");
                    cmd.Parameters.AddWithValue("@Mode", "Edit");

                    int i = cmd.ExecuteNonQuery();
                    con.Close();
                }
                else
                {
                    DataSet dsPatientCWProfile = GetPatientCWProfile();
                    foreach (DataRow NR in dsPatientCWProfile.Tables[0].Rows)
                    {
                        SqlCommand cmd2 = new SqlCommand("IUPatientCWProfile", con);
                        cmd2.CommandType = CommandType.StoredProcedure;

                        cmd2.Parameters.AddWithValue("@HospitalID", HospitalID);
                        cmd2.Parameters.AddWithValue("@LocationID", LocationID);
                        cmd2.Parameters.AddWithValue("@PatientCWProfileID", NR["PatientCWProfileID"] = 0);

                        cmd2.Parameters.AddWithValue("@ProfileID", NR["ProfileID"]               = obj.ProfileID);
                        cmd2.Parameters.AddWithValue("@GeneralCharges", NR["GeneralCharges"]     = obj.GeneralCharges);
                        cmd2.Parameters.AddWithValue("@EmergencyCharges", NR["EmergencyCharges"] = obj.EmergencyCharges);
                        cmd2.Parameters.AddWithValue("@OrganizationID", NR["OrganizationID"]);
                        cmd2.Parameters.AddWithValue("@RecommendedByDoctor", NR["RecommendedByDoctor"]);
                        cmd2.Parameters.AddWithValue("@CreationID", NR["CreationID"] = UserID);
                        cmd2.Parameters.AddWithValue("@Mode", NR["Mode"]             = "Add");
                        //NR["CreationID"] = ds.Tables[0].Rows[0]["CreationID"].ToString().Trim();
                        //NR["Mode"] = "Add";
                        con.Open();
                        int CWProfileTest = cmd2.ExecuteNonQuery();
                        con.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
        public ActionResult PatientCWProfile(PatientCWProfile obj, FormCollection fc)
        {
            BL_PatientCWProfile _PatientCWProfile = new BL_PatientCWProfile();

            Connect();
            try
            {
                obj.OrganizationID   = Convert.ToInt32(fc["OrgID"].ToString());
                obj.OrganizationName = fc["OrgName"].ToString();
                obj.ProfileID        = fc["ProfileID"].ToString();
                obj.ProfileName      = fc["ProfileName"].ToString();
                if (obj.PatientCWProfileID == "0" || obj.PatientCWProfileID == null)
                {
                    obj.PatientCWProfileID = "0";
                }
                else
                {
                    obj.PatientCWProfileID = fc["PatientCWProfileID"].ToString();
                }

                obj.GeneralCharges   = fc["GeneralChg"].ToString();
                obj.EmergencyCharges = fc["EmergChg"].ToString();


                if (_PatientCWProfile.Save(obj))
                {
                    if (Convert.ToInt32(obj.PatientCWProfileID) > 0)
                    {
                        ModelState.Clear();
                        ViewData["flag"] = "Done";
                        TempData["Msg"]  = "Record Updated Successfully ";
                    }
                    else
                    {
                        ModelState.Clear();
                        ViewData["flag"] = "Done";
                        TempData["Msg"]  = "Record Saved Successfully ";
                    }
                }
                // }
                else
                {
                    ViewData["flag"] = "Error";
                    TempData["Msg"]  = "Doesn't Save Successfully ";
                }
                return(RedirectToAction("PatientCWProfile", "PatientCWProfile"));
            }
            catch (Exception)
            {
                return(RedirectToAction("PatientCWProfile", "PatientCWProfile"));
            }
        }
        public ActionResult BindProfile(string prefix, string OrgID)
        {
            BL_PatientCWProfile     _PatientCWProfile    = new BL_PatientCWProfile();
            List <PatientCWProfile> PatientCWProfileList = new List <PatientCWProfile>();
            DataSet ds = _PatientCWProfile.BindProfile(prefix, OrgID);

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                PatientCWProfile catl = new PatientCWProfile();

                catl.ProfileID = dr["ProfileID"].ToString();

                catl.ProfileName        = dr["Name"].ToString();
                catl.PatientCWProfileID = dr["PatientCWProfileID"].ToString();
                PatientCWProfileList.Add(catl);
            }
            return(new JsonResult {
                Data = PatientCWProfileList, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }
        public ActionResult BindOrganization(string prefix)
        {
            BL_PatientCWProfile     _PatientCWProfile    = new BL_PatientCWProfile();
            List <PatientCWProfile> PatientCWProfileList = new List <PatientCWProfile>();
            DataSet ds = _PatientCWProfile.BindOrganization(prefix);
            int     i  = 0;

            foreach (DataRow dr in ds.Tables[0].Rows)
            {
                PatientCWProfile catl = new PatientCWProfile();

                catl.OrganizationID = Convert.ToInt32(dr["OrganizationID"].ToString());

                catl.OrganizationName = dr["OrganizationName"].ToString();

                PatientCWProfileList.Add(catl);
            }
            return(new JsonResult {
                Data = PatientCWProfileList, JsonRequestBehavior = JsonRequestBehavior.AllowGet
            });
        }