Ejemplo n.º 1
0
        public bool SaveTest(CollectionCenter obj)
        {
            Connect();


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

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.AddWithValue("@HospitalID", HospitalID);
            cmd.Parameters.AddWithValue("@LocationID", LocationID);
            if (obj.CollectionID == "" || obj.CollectionID == null || obj.CollectionID == "0")
            {
                cmd.Parameters.AddWithValue("@CollectionID", 0);
                cmd.Parameters.AddWithValue("@Mode", "Add");
            }
            else
            {
                cmd.Parameters.AddWithValue("@CollectionID", obj.CollectionID);
                cmd.Parameters.AddWithValue("@Mode", "Edit");
            }

            cmd.Parameters.AddWithValue("@CollectionName", obj.CollectionName);
            cmd.Parameters.AddWithValue("@PhoneNo", obj.PhoneNo);
            cmd.Parameters.AddWithValue("@MobileNo", obj.Mobile);
            cmd.Parameters.AddWithValue("@Address", obj.Address);
            cmd.Parameters.AddWithValue("@EmailID", obj.Email);
            cmd.Parameters.AddWithValue("@Admin", obj.AdminInCharge);
            cmd.Parameters.AddWithValue("@CreationID", UserID);
            con.Open();
            int i = cmd.ExecuteNonQuery();

            con.Close();
            if (i > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        public ActionResult CollectionCenter(CollectionCenter obj, FormCollection fc)
        {
            try
            {
                BL_CollectionCenter _CollectionCenter = new BL_CollectionCenter();
                if (_CollectionCenter.CheckCollectionCenter(obj.CollectionID, obj.CollectionName))
                {
                    if (obj.CollectionID == "0" || obj.CollectionID == null)
                    {
                        obj.CollectionID = "0";
                    }
                    else
                    {
                        obj.CollectionID = (fc["CollectionID"]);
                    }
                    if (obj.CollectionName == "" || obj.CollectionName == null)
                    {
                        obj.CollectionName = "";
                    }
                    else
                    {
                        obj.CollectionName = fc["CollectionName"].ToString();
                    }
                    if (obj.Mobile == "")
                    {
                        obj.Mobile = "";
                    }
                    else
                    {
                        obj.Mobile = fc["MobileNo"].ToString();
                    }
                    if (obj.PhoneNo == "")
                    {
                        obj.PhoneNo = "";
                    }
                    else
                    {
                        obj.PhoneNo = fc["Phone"].ToString();
                    }
                    if (obj.Address == "" || obj.Address == null)
                    {
                        obj.Address = "";
                    }
                    else
                    {
                        obj.Address = fc["Address"].ToString();
                    }
                    if (obj.Email == "")
                    {
                        obj.Email = "";
                    }
                    else
                    {
                        obj.Email = fc["EmailID"].ToString();
                    }
                    if (obj.AdminInCharge == "")
                    {
                        obj.AdminInCharge = "";
                    }
                    else
                    {
                        obj.AdminInCharge = fc["Admin"].ToString();
                    }
                    if (_CollectionCenter.SaveTest(obj))
                    {
                        if (Convert.ToInt32(obj.CollectionID) > 0)
                        {
                            ModelState.Clear();

                            TempData["Msg"] = "Collection Center Updated Successfully !";
                            return(RedirectToAction("CollectionCenter", "CollectionCenter"));
                        }
                        else
                        {
                            ModelState.Clear();

                            TempData["Msg"] = "Collection Center Saved Successfully !";
                            return(RedirectToAction("CollectionCenter", "CollectionCenter"));
                        }
                    }
                }
                else
                {
                    ViewData["flag"] = "Error";
                    TempData["Msg"]  = "Collection Center Already Exists !";
                }
                return(RedirectToAction("CollectionCenter", "CollectionCenter"));
            }
            catch (Exception)
            {
                return(RedirectToAction("CollectionCenter", "CollectionCenter"));
            }
        }