Пример #1
0
        protected void btnDelete_Click(object sender, EventArgs e)
        {
            try
            {
                var dataAccess = new HeroicData();
                var result     = dataAccess.ExecuteNonQuery(
                    query: "DELETE FROM [User] WHERE ID = @id;",
                    parameters: new List <HeroicData.Parameters>
                {
                    new HeroicData.Parameters {
                        Name = "@id", Value = hidID.Value
                    }
                });

                if (result == 0)
                {
                    lbl.Text    = "Record not deleted";
                    lbl.Visible = true;
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            catch (Exception ex)
            {
                lbl.Text    = "Something went wrong, Message: " + ex.Message;
                lbl.Visible = true;
            }
        }
Пример #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                var dataAccess = new HeroicData();
                var result     = dataAccess.ExecuteNonQuery(
                    query: "UPDATE [User] SET UserName = @userName, Email = @email, Mobile = @mobile, Password = @password WHERE ID = @id;",
                    parameters: new List <HeroicData.Parameters>
                {
                    new HeroicData.Parameters {
                        Name = "@id", Value = hidID.Value
                    },
                    new HeroicData.Parameters {
                        Name = "@userName", Value = txtUserName.Text
                    },
                    new HeroicData.Parameters {
                        Name = "@email", Value = txtEmail.Text
                    },
                    new HeroicData.Parameters {
                        Name = "@mobile", Value = txtMobile.Text
                    },
                    new HeroicData.Parameters {
                        Name = "@password", Value = txtPassword.Text
                    },
                });

                if (result == 0)
                {
                    lbl.Text    = "Record not updated";
                    lbl.Visible = true;
                }
                else
                {
                    Response.Redirect("~/Default.aspx");
                }
            }
            catch (Exception ex)
            {
                lbl.Text    = "Something went wrong, Message: " + ex.Message;
                lbl.Visible = true;
            }
        }