예제 #1
0
 protected void dgvGridView_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
 {
     if (!string.IsNullOrEmpty(e.CommandArgument.ToString()))
     {
         hdnPKID.Value = e.CommandArgument.ToString();
         if (e.CommandName == "IsActive")
         {
             objUser = new tblUser();
             if (objUser.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)))
             {
                 if (objUser.AppIsActive == true)
                 {
                     objUser.AppIsActive = false;
                 }
                 else if (objUser.AppIsActive == false)
                 {
                     objUser.AppIsActive = true;
                 }
                 objUser.Save();
             }
             objUser = null;
             LoadDataGrid(false, false, "", "");
         }
     }
 }
예제 #2
0
    private bool SaveData()
    {
        objClsCommon = new clsCommon();
        objUser      = new tblUser();

        if (objClsCommon.IsRecordExists("tblUser", tblUser.ColumnNames.AppUserName, tblUser.ColumnNames.AppUserId, txtUserName.Text, hdnPKID.Value))
        {
            DInfo.ShowMessage("User Name is already exists", Enums.MessageType.Warning);
            return(false);
        }

        if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
        {
            objUser.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value));
        }
        else
        {
            objUser.AddNew();
            objUser.AppCreatedDate = System.DateTime.Now;
            objUser.AppCreatedBy   = Convert.ToInt32(Session[appFunctions.Session.UserID.ToString()]);
        }
        objUser.s_AppUserName = txtUserName.Text;
        objEncrypt            = new clsEncryption();
        objUser.AppPassword   = objEncrypt.Encrypt(txtPassword.Text, appFunctions.strKey);
        objEncrypt            = null;
        objUser.s_AppRoleId   = ddlRoleName.SelectedValue;

        objUser.AppFullName     = txtFullName.Text;
        objUser.AppEmail        = txtEmailAddress.Text;
        objUser.AppMobile       = txtMobileNo.Text;
        objUser.AppAddress      = txtAddress.Text;
        objUser.AppIsActive     = chkIsActive.Checked;
        objUser.AppIsSuperAdmin = Convert.ToBoolean(0);

        if (FileUploadImg.HasFile)
        {
            objClsCommon = new clsCommon();
            string strError = "";
            string Time     = Convert.ToString(DateTime.Now.Month) + Convert.ToString(DateTime.Now.Day) + Convert.ToString(DateTime.Now.Year) + Convert.ToString(DateTime.Now.Hour) + Convert.ToString(DateTime.Now.Minute) + Convert.ToString(DateTime.Now.Second);
            string strPath  = objClsCommon.FileUpload_Images(FileUploadImg.PostedFile, txtFullName.Text.Trim().Replace(" ", "_") + "_" + Time, "Uploads/User/", ref strError, 0, objUser.s_AppPhoto);
            if (strError == "")
            {
                objUser.AppPhoto = strPath;
            }
            else
            {
                DInfo.ShowMessage(strError, Enums.MessageType.Error);
                return(false);
            }
        }
        objUser.AppDescription = txtDescription.Text;

        objUser.Save();
        iUserid      = objUser.AppUserId;
        objUser      = null;
        objClsCommon = null;
        return(true);
    }
예제 #3
0
    protected void lnkbtnRemovePhoto_Click(object sender, EventArgs e)
    {
        objUser = new tblUser();
        if (objUser.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value)))
        {
            objUser.AppPhoto = "";
            objUser.Save();
        }

        objUser = null;
    }
예제 #4
0
    private bool Delete(int intPKID)
    {
        bool retval = false;

        objUser = new tblUser();
        if (objUser.LoadByPrimaryKey(intPKID))
        {
            objUser.MarkAsDeleted();
            objUser.Save();
        }
        retval  = true;
        objUser = null;
        return(retval);
    }
예제 #5
0
    private bool SaveData()
    {
        objUser = new tblUser();
        objUser.LoadByPrimaryKey((int)Session[appFunctions.Session.UserID.ToString()]);
        objEncrypt = new clsEncryption();
        if (string.Compare(objEncrypt.Decrypt(objUser.AppPassword, appFunctions.strKey), txtOldPassword.Text) == 0)
        {
            objUser.AppPassword = objEncrypt.Encrypt(txtNewPassword.Text, appFunctions.strKey);
            objUser.Save();
            return(true);
        }

        DInfo.ShowMessage("Old Password is incorrect", Enums.MessageType.Error);
        return(false);
    }
예제 #6
0
    private bool SaveData()
    {
        objClsCommon = new clsCommon();
        objUser      = new tblUser();

        if (objClsCommon.IsRecordExists("tblUser", tblUser.ColumnNames.AppEmail, tblUser.ColumnNames.AppUserId, txtEmailAddress.Text, hdnPKID.Value))
        {
            DInfo.ShowMessage("Email Address is already exists", Enums.MessageType.Warning);
            return(false);
        }

        if (!string.IsNullOrEmpty(hdnPKID.Value) && hdnPKID.Value != "")
        {
            objUser.LoadByPrimaryKey(Convert.ToInt32(hdnPKID.Value));
        }


        objUser.AppFullName = txtFullName.Text;
        objUser.AppMobile   = txtMobileNo.Text;
        objUser.AppEmail    = txtEmailAddress.Text;
        objUser.AppAddress  = txtAddress.Text;
        if (FileUploadImg.HasFile)
        {
            objClsCommon = new clsCommon();
            string strError = "";
            string Time     = Convert.ToString(DateTime.Now.Month) + Convert.ToString(DateTime.Now.Day) + Convert.ToString(DateTime.Now.Year) + Convert.ToString(DateTime.Now.Hour) + Convert.ToString(DateTime.Now.Minute) + Convert.ToString(DateTime.Now.Second);
            string strPath  = objClsCommon.FileUpload_Images(FileUploadImg.PostedFile, txtFullName.Text.Trim().Replace(" ", "_") + "_" + Time, "Uploads/Employee/", ref strError, 0, objUser.s_AppPhoto);
            if (strError == "")
            {
                objUser.AppPhoto = strPath;
            }
            else
            {
                DInfo.ShowMessage(strError, Enums.MessageType.Error);
                return(false);
            }
        }
        objUser.Save();
        hdnPKID.Value = objUser.AppUserId.ToString();
        objUser       = null;
        return(true);
    }
예제 #7
0
    protected void btnLogIn_Click(object sender, System.EventArgs e)
    {
        clsEncryption objEncrypt = new clsEncryption();

        objAdminUser = new tblUser();
        objAdminUser.Where.AppUserName.Value = txtUserName.Text;

        try
        {
            objAdminUser.Where.AppPassword.Value = objEncrypt.Encrypt(txtPassword.Text, appFunctions.strKey.ToString());
        }
        catch (Exception ex)
        {
            lblMsg.Text = "Invalid Username or Password";
            SaveLog(false);
            return;
        }

        objAdminUser.Query.Load();


        if (objAdminUser.RowCount > 0)
        {
            if (objAdminUser.AppIsActive)
            {
                if (chkRemeber.Checked)
                {
                    httpCookie         = new HttpCookie("JetAPIAdminUsername", objEncrypt.Encrypt(txtUserName.Text, appFunctions.strKey));
                    httpCookie.Expires = DateTime.Today.AddDays(10);
                    Response.Cookies.Add(httpCookie);

                    httpCookie         = new HttpCookie("JetAPIAdminPassword", objEncrypt.Encrypt(txtPassword.Text, appFunctions.strKey));
                    httpCookie.Expires = DateTime.Today.AddDays(10);
                    Response.Cookies.Add(httpCookie);
                }
                else
                {
                    httpCookie         = new HttpCookie("JetAPIAdminUsername", "");
                    httpCookie.Expires = DateTime.Today.AddDays(0);
                    Response.Cookies.Add(httpCookie);

                    httpCookie         = new HttpCookie("JetAPIAdminPassword", "");
                    httpCookie.Expires = DateTime.Today.AddDays(0);
                    Response.Cookies.Add(httpCookie);
                }

                Session[appFunctions.Session.UserID.ToString()]       = objAdminUser.AppUserId;
                Session[appFunctions.Session.RoleID.ToString()]       = objAdminUser.AppRoleId;
                Session[appFunctions.Session.UserName.ToString()]     = objAdminUser.AppUserName;
                Session[appFunctions.Session.EmployeeName.ToString()] = objAdminUser.AppFullName;
                Session[appFunctions.Session.IsSuperAdmin.ToString()] = objAdminUser.AppIsSuperAdmin;


                objAdminUser.AppLastLoginTime = DateTime.Now;
                objAdminUser.Save();
                SaveLog(true);

                if ((bool)Session[appFunctions.Session.IsSuperAdmin.ToString()] == false)
                {
                    tblPermission objPermission = new tblPermission();

                    bool hasDashboardPermission = objPermission.CheckDeshbordTab(Session[appFunctions.Session.RoleID.ToString()].ToString());  //objPermission.CheckDeshbordTab(Session[appFunctions.Session.RoleID.ToString()].ToString());
                    if (hasDashboardPermission)
                    {
                        Response.Redirect("Dashboard.aspx");
                    }
                    else
                    {
                        Response.Redirect("UserPanel.aspx");
                    }
                }
                else
                {
                    Response.Redirect("Dashboard.aspx");
                }
            }
            else
            {
                lblMsg.Text = "Your account is disabled, Contact to administrator.";
                SaveLog(false);
            }
        }
        else
        {
            lblMsg.Text = "Invalid Username or Password";
            SaveLog(false);
        }
    }