protected void Button1_Click(object sender, EventArgs e) { db.Execute("update users set status=-10 where id_user="******"message"] = "Your account has been canceled."; FormsAuthentication.SignOut(); Response.Redirect("/"); }
public void BuyCreditsDB(double amount_money, int credits, int id_user) { DB_Helper db = new DB_Helper(); db.Execute("exec BUY_CREDITS " + id_user + "," + amount_money + "," + credits); MyUtils.RefreshUserRow(); }
protected void Page_Load(object sender, EventArgs e) { try { lblAcitvated.Text = ""; if (Request.QueryString["id"] != null) { string[] ids = Request.QueryString["id"].Split(new char[] { '-' }, 2); int id = -1; if (int.TryParse(ids[0], out id) && ids[1] == Hash.CalculateMD5HashWithSalt(ids[0])) { db.Execute(string.Format("update Users set email_verified=1 where id_user = {0}", id)); MyUtils.RefreshUserRow(); lblAcitvated.Text = "Your account has been activated."; if (MyUtils.IsLoggedIn()) { Session["message"] = lblAcitvated.Text; Response.Redirect("/Account/", true); return; } } } if (lblAcitvated.Text == "") { lblAcitvated.Text = "Your account has not been activated. Check you activation email for correct link."; } } finally { db.CommandBuilder_Disconnect(); } }
private void DeletePhotoToDb(int idPhoto, bool isMain) { try { if (isMain) { db.Execute(string.Format("update users set id_photo = null where id_user={0}", (int)MyUtils.GetUserField("id_user"))); Session["MainPhotoGuid"] = null; MyUtils.RefreshUserRow(); } db.Execute(string.Format("delete from photos where id_photo={0}", idPhoto)); } finally { db.CommandBuilder_Disconnect(); } }
protected void btnSendCode_Click(object sender, EventArgs e) { if (regexEmailValid.IsValid && RequiredFieldValidator1.IsValid) { DB_Helper db = new DB_Helper(); string em = txtEmail.Text; if (em.StartsWith("ACTIVATE")) { db.Execute(string.Format("update Users set email_verified=1 where id_user = {0}", MyUtils.ID_USER)); MyUtils.RefreshUserRow(); } else { int id_user = db.ExecuteScalarInt("select id_user from users where email=" + MyUtils.safe(em), 0); if (id_user > 0 && id_user != MyUtils.ID_USER) { Session["message"] = "ERROR: This email is already used by a different user."; return; } db.Execute("update users set email=" + MyUtils.safe(em) + " where id_user="******"EMAIL_ACTIVATE", MyUtils.ID_USER); Session["message"] = "OK: Activation email was sent. Please check your inbox."; } } else { Session["message"] = "ERROR: Invalid email."; } bool needtoverify = Convert.ToUInt32(MyUtils.GetUserField("email_verified")) == 0; if (!needtoverify) { Response.Redirect("/Account/"); Session["message"] = "Account is active."; } }
private void SetupBillingAndUpgradeMembership(double amount) { db.Execute("update users set membership='VIP',SUBSCRIPTION_ACTIVE=1,CANCEL_FROM_NEXT_PERIOD=null,NextPaymentDate=CONVERT(DATE, dateadd(month,1,getdate()), 101),UnsuccessfullCount=0,Rate=" + MyUtils.MonthlyFee.ToString() + ",NextBillingCycle=CONVERT(DATE, dateadd(month,1,getdate()), 101),LastPaymentDate=CONVERT(DATE, getdate(), 101) where id_user="******"emailtitle:Your membership has been upgraded"); p.Add("line:Your membership has been upgraded to VIP."); p.Add("cost:" + amount.ToString("c2")); p.Add("date:" + DateTime.Now.ToString("MM/dd/yyyy")); p.Add("package: Monthly Service"); RWorker.AddToEmailQueue("EMAIL_PAYMENT", MyUtils.ID_USER, null, false, p); MyUtils.RefreshUserRow(); }
protected void btnLogin_Click(object sender, EventArgs e) { if (MyUtils.authenticate(LoginUser.UserName, LoginUser.Password, out membership) && !Utils.IsUserBan()) { bool CreatePersistentCookie = this.LoginUser.RememberMeSet; //even if you close browser the account will stay logged in if (!MyUtils.IsUserAdmin()) { DB_Helper db = new DB_Helper(); db.Execute(string.Format("update Users set [lastlogin_time] = getdate(), ip_address={1} where id_user = {0}", MyUtils.ID_USER,MyUtils.safe(MyUtils.GetIP()))); } FormsAuthentication.RedirectFromLoginPage(LoginUser.UserName, CreatePersistentCookie); } }
protected void btnLogin_Click(object sender, EventArgs e) { if (MyUtils.authenticate(LoginUser.UserName, LoginUser.Password, out membership) && !Utils.IsUserBan()) { bool CreatePersistentCookie = this.LoginUser.RememberMeSet; //even if you close browser the account will stay logged in if (!MyUtils.IsUserAdmin()) { DB_Helper db = new DB_Helper(); db.Execute(string.Format("update Users set [lastlogin_time] = getdate(), ip_address={1} where id_user = {0}", MyUtils.ID_USER, MyUtils.safe(MyUtils.GetIP()))); } FormsAuthentication.RedirectFromLoginPage(LoginUser.UserName, CreatePersistentCookie); } }
protected void btnSendCode_Click(object sender, EventArgs e) { if (regexEmailValid.IsValid && RequiredFieldValidator1.IsValid) { DB_Helper db = new DB_Helper(); string em =txtEmail.Text; if (em.StartsWith("ACTIVATE")) { db.Execute(string.Format("update Users set email_verified=1 where id_user = {0}", MyUtils.ID_USER)); MyUtils.RefreshUserRow(); } else { int id_user = db.ExecuteScalarInt("select id_user from users where email=" + MyUtils.safe(em), 0); if (id_user > 0 && id_user != MyUtils.ID_USER) { Session["message"] = "ERROR: This email is already used by a different user."; return; } db.Execute("update users set email=" + MyUtils.safe(em) + " where id_user="******"EMAIL_ACTIVATE", MyUtils.ID_USER); Session["message"] = "OK: Activation email was sent. Please check your inbox."; } } else Session["message"] = "ERROR: Invalid email."; bool needtoverify = Convert.ToUInt32(MyUtils.GetUserField("email_verified")) == 0; if (!needtoverify) { Response.Redirect("/Account/"); Session["message"] = "Account is active."; } }
public void BuyCreditsDB(double amount_money, int credits, int id_user) { DB_Helper db = new DB_Helper(); db.Execute("exec BUY_CREDITS " + id_user + "," + amount_money + "," + credits); List<string> p = new List<string>(); p.Add("emailtitle:Credits were added"); p.Add("line:We added " + credits + " credits to your account."); p.Add("credits:" + credits); p.Add("cost:" + amount_money.ToString("c2")); p.Add("date:" + DateTime.Now.ToString("MM/dd/yyyy")); p.Add("package:" + credits + " credit package"); RWorker.AddToEmailQueue("EMAIL_PAYMENT", MyUtils.ID_USER, null, false, p); MyUtils.RefreshUserRow(); }
public void BuyCreditsDB(double amount_money, int credits, int id_user) { DB_Helper db = new DB_Helper(); db.Execute("exec BUY_CREDITS " + id_user + "," + amount_money + "," + credits); List <string> p = new List <string>(); p.Add("emailtitle:Credits were added"); p.Add("line:We added " + credits + " credits to your account."); p.Add("credits:" + credits); p.Add("cost:" + amount_money.ToString("c2")); p.Add("date:" + DateTime.Now.ToString("MM/dd/yyyy")); p.Add("package:" + credits + " credit package"); RWorker.AddToEmailQueue("EMAIL_PAYMENT", MyUtils.ID_USER, null, false, p); MyUtils.RefreshUserRow(); }
static DataTable SaveMessage2DBAndSelect(int id_user_from, int id_user_to, string message, string gift_list, int id_offer) { DB_Helper db = new DB_Helper(); string s = ""; if (MyUtils.IsFemale) { s = "select female_sent_msg from offers where id_offer=" + id_offer; int female_sent_msg = db.ExecuteScalarIntCache(s, 0, 5); if (female_sent_msg == 0) { db.Execute("update offers set female_sent_msg=1 where isnull(female_sent_msg,0)=0 and id_offer=" + id_offer + "; "); DB_Helper.InvalidateCache("SQL_" + s); } } return(db.GetDataSet("insert into messages (id_user_from,id_user_to,text,gift_list,id_offer) OUTPUT inserted.* values (" + id_user_from + "," + id_user_to + "," + MyUtils.safe(message) + "," + MyUtils.safe(gift_list) + "," + id_offer + ");").Tables[0]); }
private static void EnsureFilterIsSaved(Filter f) { string user_filter = MyUtils.GetUserField("filter") as string; string current_filter = f.ToString(); if (user_filter != current_filter) { DB_Helper db = new DB_Helper(); int id_user = MyUtils.ID_USER; //currently logged in user if (f.IsDefault()) { current_filter = "DEFAULT"; } db.Execute("update users set filter=" + MyUtils.safe(current_filter) + " where id_user=" + id_user); MyUtils.RefreshUserRow(); } }
protected void btnBlock_Click(object sender, EventArgs e) { // Block if ((sender as LinkButton).Text == "Block") { int newBlockId = 0; //Insert a new block to blocks table try { DataSet ds = db.CommandBuilder_LoadDataSet("select * from blocks where id =-1"); //get the columns schema DataRow newBlock = ds.Tables[0].NewRow(); newBlock["id_user_child"] = (int)MyUtils.GetUserField("id_user"); newBlock["id_user"] = currentUser; newBlock["time"] = DateTime.Now; ds.Tables[0].Rows.Add(newBlock); newBlockId = db.CommandBuilder_SaveDataset(); SetButtonBlock(true); } finally { db.CommandBuilder_Disconnect(); } } //Unblock else { try { db.Execute(string.Format("delete from blocks where id_user_child={0} and id_user = {1}", (int)MyUtils.GetUserField("id_user"), currentUser)); SetButtonBlock(false); } finally { db.CommandBuilder_Disconnect(); } } }
private static void EnsureFilterIsSaved(Filter f) { string user_filter = MyUtils.GetUserField("filter") as string; string current_filter = f.ToString(); if (user_filter != current_filter) { DB_Helper db = new DB_Helper(); int id_user = MyUtils.ID_USER; //currently logged in user if (f.IsDefault()) current_filter = "DEFAULT"; db.Execute("update users set filter=" + MyUtils.safe(current_filter) + " where id_user=" + id_user); MyUtils.RefreshUserRow(); } }