Exemplo n.º 1
0
 /// <summary>
 /// Action use for insert new admin user 
 /// </summary>
 /// <returns></returns>
 public ActionResult AddAdminuser(AdminUser objModel)
 {
     try
     {
         objModel.objGHC_AdminUsersData.dDateAdded = DateTime.Now;
         objModel.objGHC_AdminUsersData.sPassword = (Methods.CorrectDBNull(objModel.objGHC_AdminUsersData.sPassword) != "") ? Methods.Encryption(objModel.objGHC_AdminUsersData.sPassword) : "";
         GHC_AdminUsersData objAddAdmin = new GHC_AdminUsersData();
         objAddAdmin.sFirstName =Methods.doInsertable(objModel.objGHC_AdminUsersData.sFirstName);
         objAddAdmin.sLastName = Methods.doInsertable(objModel.objGHC_AdminUsersData.sLastName);
         objAddAdmin.sEmail = Methods.doInsertable(objModel.objGHC_AdminUsersData.sEmail);
         objAddAdmin.sPassword = Methods.doInsertable(objModel.objGHC_AdminUsersData.sPassword);
         objAddAdmin.sCity = Methods.doInsertable(objModel.objGHC_AdminUsersData.sCity);
         objAddAdmin.sZipCode = Methods.doInsertable(objModel.objGHC_AdminUsersData.sZipCode);
         objAddAdmin.nStateID = Methods.doInt(objModel.objGHC_AdminUsersData.nStateID);
         objAddAdmin.nCountryID = Methods.doInt(objModel.objGHC_AdminUsersData.nCountryID);
         objAddAdmin.bIsActive = Methods.doBoolean(objModel.objGHC_AdminUsersData.bIsActive);
         objAddAdmin.dDateAdded = DateTime.Now;
         objAddAdmin.nModifiedBy = Methods.doLong(Session[CommonConstants.LoggedInUserID]);
         int nReturn = objDBGHC_AdminUsers.GHC_AdminUsers_Insert(objAddAdmin);
         if (nReturn > 0)
         {
             Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Insert]", "Admin User");
             Session[Helpers.CommonConstants.MessageType] = "1";
         }
         else
         {
             Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Error]", "Admin User");
             Session[Helpers.CommonConstants.MessageType] = "2";
         }
     }
     catch (Exception ex)
     {
         CommonRepository.LogError("AdminUserController", "AddAdminuser", ex.ToString());
         Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Error]");
         Session[Helpers.CommonConstants.MessageType] = "2";
         return RedirectToAction("index");
     }
     return RedirectToAction("ViewAdminUser");
 }
Exemplo n.º 2
0
        /// <summary>
        /// Action to open the Add Admin user page
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult CreateAdminUser(string id = "0")
        {
            try
            {
                AdminUser objUserinfo = new AdminUser();
                int nUserId = Methods.doInt(Methods.base64Decode(id));
                var nRecord = new GHC_AdminUsersData();
                if (nUserId > 0)
                {
                    // GET USER INFORMATION
                    DataRow dr = objDBGHC_AdminUsers.GHC_AdminUsers_GetAllById(nUserId);
                    if(dr != null)
                    {
                        nRecord.nAdminUserID = Methods.doLong(dr["nAdminUserID"]);
                        nRecord.sFirstName = Methods.CorrectDBNull(dr["sFirstName"]);
                        nRecord.sLastName = Methods.CorrectDBNull(dr["sLastName"]);
                        nRecord.sEmail = Methods.CorrectDBNull(dr["sEmail"]);
                        nRecord.sPassword = Methods.CorrectDBNull(dr["sPassword"]);
                        nRecord.sCity = Methods.CorrectDBNull(dr["sCity"]);
                        nRecord.nStateID = Methods.doInt(dr["nStateID"]);
                        nRecord.sZipCode = Methods.CorrectDBNull(dr["sZipCode"]);
                        nRecord.nCountryID = Methods.doInt(dr["nCountryID"]);
                        nRecord.bIsActive = Methods.doBoolean(dr["bIsActive"]);
                    }

                }
                objUserinfo.objGHC_AdminUsersData = nRecord;

                return View("Index", objUserinfo);
            }
            catch (Exception ex)
            {
                CommonRepository.LogError("AdminUserController", "CreateAdminUser", ex.ToString());
                Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Error]");
                Session[Helpers.CommonConstants.MessageType] = "2";
                return RedirectToAction("index");
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// Action use for updating current admin user details
 /// </summary>
 /// <returns></returns>
 public ActionResult UpdateAdminuser(AdminUser objModel, FormCollection form)
 {
     try
     {
         GHC_AdminUsersData objAdminusers = new GHC_AdminUsersData();
         int nAdminuserID = Convert.ToInt32(Request.Form["hdnAdminUserID"]);
         objModel.objGHC_AdminUsersData.sPassword = (Methods.CorrectDBNull(objModel.objGHC_AdminUsersData.sPassword) != "") ? Methods.Encryption(objModel.objGHC_AdminUsersData.sPassword) : "";
         objAdminusers.nAdminUserID = nAdminuserID;
         objAdminusers.sFirstName = Methods.doInsertable(objModel.objGHC_AdminUsersData.sFirstName);
         objAdminusers.sLastName = Methods.doInsertable(objModel.objGHC_AdminUsersData.sLastName);
         objAdminusers.sEmail = Methods.doInsertable(objModel.objGHC_AdminUsersData.sEmail);
         objAdminusers.sPassword = Methods.doInsertable(objModel.objGHC_AdminUsersData.sPassword);
         objAdminusers.sCity = Methods.doInsertable (objModel.objGHC_AdminUsersData.sCity);
         objAdminusers.nStateID = Methods.doInt(objModel.objGHC_AdminUsersData.nStateID);
         objAdminusers.sZipCode = Methods.doInsertable(objModel.objGHC_AdminUsersData.sZipCode);
         objAdminusers.nCountryID = Methods.doInt(objModel.objGHC_AdminUsersData.nCountryID);
         objAdminusers.bIsActive = Methods.doBoolean(objModel.objGHC_AdminUsersData.bIsActive);
         objAdminusers.dDateModified = DateTime.Now;
         objAdminusers.nModifiedBy = Methods.doLong(Session[CommonConstants.LoggedInUserID]);
         int nReturn = objDBGHC_AdminUsers.GHC_AdminUsers_Update(objAdminusers);
         if (nReturn > 0)
         {
             Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Update]", "Admin User");
             Session[Helpers.CommonConstants.MessageType] = "1";
         }
         else if (nReturn == -1)
         {
             Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Exists]", "Email");
             Session[Helpers.CommonConstants.MessageType] = "2";
         }
         else
         {
             Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Error]", "Admin User");
             Session[Helpers.CommonConstants.MessageType] = "2";
         }
     }
     catch (Exception ex)
     {
         CommonRepository.LogError("AdminUserController", "UpdateAdminuser", ex.ToString());
         Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Error]", "Admin User");
         Session[Helpers.CommonConstants.MessageType] = "2";
         return RedirectToAction("index");
     }
     return RedirectToAction("ViewAdminUser");
 }
Exemplo n.º 4
0
        /// <summary>
        /// Action to open the Admin user listing page
        /// </summary>
        /// <returns></returns>
        public ActionResult ViewAdminUser()
        {
            try
            {
                AdminUser objAdminUser = new AdminUser();
                DataSet ds = objDBGHC_AdminUsers.GHC_AdminUsers_GetAll("dDateAdded", "DESC", 0, 100000, "", "");
                //AdminUser objAdminUser = new AdminUser();
                if (ds != null && ds.Tables[1] != null)
                {
                    List<GHC_AdminUsersData> sList = new List<GHC_AdminUsersData>();
                    //sList.ToList().Add(ds.Tables[1]);
                    foreach (DataRow row in ds.Tables[1].Rows)
                    {
                        var nRecord = new GHC_AdminUsersData();
                        nRecord.nAdminUserID = Methods.doLong(row["nAdminUserID"]);
                        nRecord.sFirstName = Methods.CorrectDBNull(row["sFirstName"]);
                        nRecord.sLastName = Methods.CorrectDBNull(row["sLastName"]);
                        nRecord.sEmail = Methods.CorrectDBNull(row["sEmail"]);
                        nRecord.sPassword = Methods.CorrectDBNull(row["sPassword"]);
                        nRecord.sCity = Methods.CorrectDBNull(row["sCity"]);
                        nRecord.nStateID = Methods.doInt(row["nStateID"]);
                        nRecord.sZipCode = Methods.CorrectDBNull(row["sZipCode"]);
                        nRecord.nCountryID = Methods.doInt(row["nCountryID"]);
                        nRecord.bIsActive = Methods.doBoolean(row["bIsActive"]);
                        sList.Add(nRecord);
                    }
                    objAdminUser.objGHC_AdminUserList = sList;
                }

                return View(objAdminUser);
            }
            catch (Exception ex)
            {
                CommonRepository.LogError("AdminUserController", "ViewAdminUser", ex.ToString());
                Session[Helpers.CommonConstants.Message] = Messages.GetMessage("[Error]");
                Session[Helpers.CommonConstants.MessageType] = "2";
                return RedirectToAction("index");
            }
        }
Exemplo n.º 5
0
 public int GHC_AdminUsers_Update(GHC_AdminUsersData ObjGHC_AdminUsersData)
 {
     int rowsAffected = 0;
     SqlConnection connection = null;
     try
     {
         connection = (SqlConnection)new DBConnect().ConnectionObject;
         SqlCommand Command = new SqlCommand("GHC_GHC_AdminUsers_Update", connection);
         Command.CommandType = CommandType.StoredProcedure;
         Command.Parameters.AddWithValue("@nAdminUserID", ObjGHC_AdminUsersData.nAdminUserID);
         Command.Parameters.AddWithValue("@sFirstName", ObjGHC_AdminUsersData.sFirstName);
         Command.Parameters.AddWithValue("@sLastName", ObjGHC_AdminUsersData.sLastName);
         Command.Parameters.AddWithValue("@sEmail", ObjGHC_AdminUsersData.sEmail);
         Command.Parameters.AddWithValue("@sPassword", ObjGHC_AdminUsersData.sPassword);
         Command.Parameters.AddWithValue("@sCity", ObjGHC_AdminUsersData.sCity);
         Command.Parameters.AddWithValue("@nStateID", ObjGHC_AdminUsersData.nStateID);
         Command.Parameters.AddWithValue("@sZipCode", ObjGHC_AdminUsersData.sZipCode);
         Command.Parameters.AddWithValue("@nCountryID", ObjGHC_AdminUsersData.nCountryID);
         Command.Parameters.AddWithValue("@bIsActive", ObjGHC_AdminUsersData.bIsActive);
         //Command.Parameters.AddWithValue("@dDateAdded",ObjGHC_AdminUsersData.dDateAdded);
         Command.Parameters.AddWithValue("@dDateModified", ObjGHC_AdminUsersData.dDateModified);
         Command.Parameters.AddWithValue("@nModifiedBy", ObjGHC_AdminUsersData.nModifiedBy);
         SqlParameter returnValueParam = new SqlParameter("@RETURN_VALUE", SqlDbType.Int);
         returnValueParam.Direction = ParameterDirection.ReturnValue;
         Command.Parameters.Add(returnValueParam);
         connection.Open();
         Command.ExecuteNonQuery();
         rowsAffected = Convert.ToInt32(returnValueParam.Value);
     }
     catch
     {
         rowsAffected = 0;
     }
     finally
     {
         if (connection != null)
             connection.Close();
         connection.Dispose();
     }
     return rowsAffected;
 }