Exemplo n.º 1
0
        protected void UserRegistration_Save(object sender, EventArgs e)
        {
            int    UserId = 0;
            string Errmsg = "";

            try
            {
                if (Connection == null)
                {
                    Connection.Open();
                }
                Connection.Open();

                string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "GetUserTypeId");
                Query = Query.Replace("_TypeName_", UserType.SelectedValue.ToString());
                long UserTypeId = QueryObj.GetSingleNumericValueViaQuery(Query, null, Connection);

                string Pass = "";
                using (var cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = "SP_UserLogin_SAVE";
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.AddWithValue("@UserId", UserId);
                    cmd.Parameters.AddWithValue("@UserName", UserName.Text);
                    cmd.Parameters.AddWithValue("@FirstName", ComputerName.Text);
                    cmd.Parameters.AddWithValue("@LastName", ComputerMacAddress.Text);
                    cmd.Parameters.AddWithValue("@Email", Email.Text);
                    cmd.Parameters.AddWithValue("@Password", Pass);
                    cmd.Parameters.AddWithValue("@CreatedBy", 1);
                    cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@LastModifyBy", 1);
                    cmd.Parameters.AddWithValue("@LastModifyDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@UserTypeId", UserTypeId);
                    cmd.ExecuteNonQuery();
                    //UserId = (int)cmd.Parameters["@UserId"].Value;
                }
            }

            catch (Exception ex)
            {
                Errmsg = ex.Message;
            }
            finally
            {
                Connection.Close();
                if (Errmsg == "")
                {
                    string message4 = UserName + " your access request successfully sended to admin";
                    System.Text.StringBuilder sb3 = new System.Text.StringBuilder();
                    sb3.Append("<script type = 'text/javascript'>");
                    sb3.Append("window.onload=function(){");
                    sb3.Append("alert('");
                    sb3.Append(message4);
                    sb3.Append("')};");
                    sb3.Append("</script>");
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb3.ToString());
                    Response.Redirect("Login.aspx");
                }
            }
        }
Exemplo n.º 2
0
        protected void LoginUser_Click(object sender, EventArgs e)
        {
            Registrations registrationObj = new Registrations();
            string        Pass            = registrationObj.encryptpass(Password.Text);


            GenerateQuery QueryObj = new GenerateQuery();

            string[,] ReplaceValues = new string[2, 2];
            ReplaceValues[0, 0]     = "_UserName_";
            ReplaceValues[0, 1]     = UserName.Text;
            ReplaceValues[1, 0]     = "_Password_";
            ReplaceValues[1, 1]     = Password.Text;
            long   UserId = 0;
            string User   = "";

            Registration registration = null;

            string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "ValidUserOrNot");

            Query = Query.Replace("_UserName_", UserName.Text.ToString());
            Query = Query.Replace("_Password_", Password.Text.ToString());
            if (Query != "")
            {
                UserId = QueryObj.GetSingleNumericValueViaQuery(Query, ReplaceValues, Connection);
                User   = QueryObj.GetSingleStringValueViaQuery(Query, ReplaceValues, Connection);
                if (UserId > 0)
                {
                    Response.Redirect("ListPage.aspx?UserId=" + UserId);
                }
                else
                {
                    UserName.Text = "";
                    Password.Text = "";
                    Label1.Text   = "Enter User Name And Password is incurrect please try again.";
                }
            }
            if (Query != "")
            {
                registration = QueryObj.GetCollectionOfDataViaQuery(Query);
                DataTable DataTableObj = new DataTable("DataTable");
                DataTableObj = QueryObj.GetCollectionOfDataSetViaQuery(Query);
                if (DataTableObj != null)
                {
                    //Data Set havinf data now retrive it to its sutiable properties
                }
            }
            if (Query != "")
            {
                registration = QueryObj.GetCollectionSearchDataViaQuery(Query, ReplaceValues, null, null, "", registration);
            }
        }
Exemplo n.º 3
0
        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                if (Connection == null)
                {
                    Connection.Open();
                }
                Connection.Open();

                string Query = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "GetUserTypeId");
                Query = Query.Replace("_TypeName_", "Admin");
                long UserTypeId = QueryObj.GetSingleNumericValueViaQuery(Query, null, Connection);

                string Pass = encryptpass(Password.Text);
                using (var cmd = Connection.CreateCommand())
                {
                    cmd.CommandText = "SP_UserLogin_SAVE";
                    cmd.CommandType = CommandType.StoredProcedure;
                    long UserId = 0;
                    cmd.Parameters.AddWithValue("@UserId", UserId);
                    cmd.Parameters.AddWithValue("@UserName", UserName.Text);
                    cmd.Parameters.AddWithValue("@FirstName", FirstName.Text);
                    cmd.Parameters.AddWithValue("@LastName", LastName.Text);
                    cmd.Parameters.AddWithValue("@Email", Email.Text);
                    cmd.Parameters.AddWithValue("@Password", Pass);
                    cmd.Parameters.AddWithValue("@CreatedBy", 1);
                    cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@LastModifyBy", 1);
                    cmd.Parameters.AddWithValue("@LastModifyDate", DateTime.Now);
                    cmd.Parameters.AddWithValue("@UserTypeId", UserTypeId);
                    cmd.ExecuteNonQuery();
                }
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }
            finally
            {
                Connection.Close();
                Response.Redirect("Login.aspx");
            }
        }
Exemplo n.º 4
0
        protected void ApproveReject_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string Message = "";

            try
            {
                if (Connection == null)
                {
                    Connection.Open();
                }
                int           index = Convert.ToInt32(e.CommandArgument);
                GridViewRow   row   = GridView1.Rows[index];
                long          RemoteControlSessionId = Convert.ToInt64(row.Cells[0].Text);
                string        AlredyApproved         = Convert.ToString(row.Cells[3].Text).ToString();
                GenerateQuery QueryObj = new GenerateQuery();
                string        Query    = QueryObj.GetQueryViaFileAndTagName("LogIn.xml", "GetUserId");
                Query = Query.Replace("_RemoteControlSessionId_", RemoteControlSessionId.ToString());
                long UserId = QueryObj.GetSingleNumericValueViaQuery(Query, null, Connection);
                if (e.CommandName == "Reject")
                {
                    Connection.Open();
                    using (var cmd = Connection.CreateCommand())
                    {
                        cmd.CommandText = "SP_RemoteControlSession_Delete";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@RemoteControlSessionId", RemoteControlSessionId);
                        cmd.ExecuteNonQuery();
                        Message = "Selected User Request Rejected.";
                    }
                }
                if (e.CommandName == "Approved" && AlredyApproved == "N")
                {
                    Connection.Open();
                    using (var cmd = Connection.CreateCommand())
                    {
                        cmd.CommandText = "SP_RemoteControlSession_SAVE";
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.AddWithValue("@RemoteControlSessionId", RemoteControlSessionId);
                        cmd.Parameters.AddWithValue("@UserId", UserId);
                        cmd.Parameters.AddWithValue("@Reject", 'N');
                        cmd.Parameters.AddWithValue("@Approved", 'Y');
                        cmd.Parameters.AddWithValue("@CreatedBy", UserId);
                        cmd.Parameters.AddWithValue("@CreatedDate", DateTime.Now);
                        cmd.Parameters.AddWithValue("@LastModifyBy", UserId);
                        cmd.Parameters.AddWithValue("@LastModifyDate", DateTime.Now);
                        cmd.ExecuteNonQuery();
                        Message = "Selected User Request Get Approved.";
                    }
                }
                else
                {
                    Message = "Selected User are alredy Approved.";
                }
            }
            catch (Exception ex)
            {
                Message = ex.Message;
            }
            finally
            {
                Connection.Close();
                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                sb.Append("<script type = 'text/javascript'>");
                sb.Append("window.onload=function(){");
                sb.Append("alert('");
                sb.Append(Message);
                sb.Append("')};");
                sb.Append("</script>");
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", sb.ToString());
                Page_Load(sender, e);
            }
        }