private void checkVerificationCode() { DB_contextDataContext db = new DB_contextDataContext(); UserLoginData logindataTable = db.UserLoginDatas.SingleOrDefault(x => x.username == this.LoggedUName); UserAddr userAddresTab = db.UserAddrs.SingleOrDefault(x => x.userID == this.LoggedUName); UserDtail userDetailsTable = db.UserDtails.SingleOrDefault(x => x.userID == this.LoggedUName); BloodData userBloodTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName); if (logindataTable != null && userAddresTab != null && userDetailsTable != null && userBloodTable != null) { if (logindataTable.verfication == code) { logindataTable.confirmVerification = this.txtConfirm.Text; userAddresTab.accountstatus = "activated"; userDetailsTable.accountstatus = "activated"; userBloodTable.accountstatus = "activated"; db.SubmitChanges(); this.userLoginForm.isChecked = true; this.lableStatus.Text = "Account Activating....."; Thread.Sleep(4000); userHomePage userForm = new userHomePage(); userForm.showLoggedUser(LoggedUName); this.Hide(); userForm.Show(); } else { this.lableStatus.Text = "Invalid Code"; this.txtConfirm.Clear(); } } }
private void sendEmail(UserLoginData updateData) { string generateTime = DateTime.Now.Millisecond.ToString(); this.FinalPass = FinalPass + generateTime; string from = "*****@*****.**"; string to = this.emailBox.Text; string subject = "BBM Password Reset"; string body = "HI ! " + updateData.username + "\n" + "Your New Password Is : " + this.FinalPass; MailMessage mail = new MailMessage(from, to, subject, body); SmtpClient client = new SmtpClient("smtp.gmail.com"); //gmail's prtovided SMTP server for mailing client.Port = 587; //SMTP port client.Credentials = new NetworkCredential(this.smtpHost, this.smtpPass); //email authentication client.EnableSsl = true; //opening SSL port try { client.Send(mail); // updateData.password = this.FinalPass; //updating DB with the new generated password db.SubmitChanges(); MessageBox.Show("Mail Send !"); } catch (SmtpException exp) { MessageBox.Show("Sending Failure"); } }
private void delFromBloodDataTable() { DB_contextDataContext db = new DB_contextDataContext(); var pendingUsers = from userBloodTab in db.BloodDatas where userBloodTab.accountstatus == "pending" select userBloodTab; db.BloodDatas.DeleteAllOnSubmit(pendingUsers); db.SubmitChanges(); }
private void delFromUserDetailsTable() { DB_contextDataContext db = new DB_contextDataContext(); var pendingUsers = from usersDetaisTab in db.UserDtails where usersDetaisTab.accountstatus == "pending" select usersDetaisTab; db.UserDtails.DeleteAllOnSubmit(pendingUsers); db.SubmitChanges(); }
private void delFromUserLoginTable() { DB_contextDataContext db = new DB_contextDataContext(); //UserLoginData loginTable; var pendingUsers = from userLoginTab in db.UserLoginDatas where userLoginTab.confirmVerification == null select userLoginTab; db.UserLoginDatas.DeleteAllOnSubmit(pendingUsers); db.SubmitChanges(); }
private void btnDelete_Click(object sender, EventArgs e) { this.deleteUserLogin(); this.deleteUserAddress(); this.deleteUserDetails(); this.deleteBloodData(); db.SubmitChanges(); this.relode(); //this.reloadAdminPage(); this.LableStatus.Text = this.uName + " Has Been Deleted"; }
private void updateBloodQuantity(int uReqQuantity) //only for request blood { BloodData bDataTable = db.BloodDatas.SingleOrDefault(x => x.userID == this.LoggedUName); BloodInventory bloodInvTable = db.BloodInventories.SingleOrDefault(x => x.bloodgroup == this.bloodGroup); if (bloodInvTable != null && bDataTable != null) { this.bloodQuantity -= uReqQuantity; //i was here bloodInvTable.bloodquantity = this.bloodQuantity; //db.SubmitChanges(); bDataTable.requested += int.Parse(this.txtBloodQuantity.Text.ToString()); //it was not updating db.SubmitChanges(); this.addToHistory(uReqQuantity); MessageBox.Show("Request Accepted" + bDataTable.requested.ToString()); } else { MessageBox.Show("DB not Updated"); } }
private void insertAddressTable() { try { this.userAddressTable.userID = this.txtboxUserName.Text; this.userAddressTable.firstName = this.txtboxFirstName.Text; this.userAddressTable.lastName = this.txtboxLastName.Text; this.userAddressTable.mobileNo = this.txtboxMobile.Text; this.userAddressTable.email = this.txtboxEmail.Text; this.userAddressTable.district = this.txtboxDistrict.Text; this.userAddressTable.subDistrict = this.txtboxSubDistrict.Text; this.userAddressTable.postalCode = this.txtboxPostal.Text; this.userAddressTable.accountstatus = "pending"; db.UserAddrs.InsertOnSubmit(this.userAddressTable); //Adding In DB db.SubmitChanges(); }catch (SqlException sqlEx) { MessageBox.Show("Address Not Inserted"); } }
private bool updateAddress() { UserAddr addressData = db.UserAddrs.SingleOrDefault(x => x.userID == this.uName); if (addressData != null) { addressData.firstName = this.txtFirstName.Text; addressData.lastName = this.txtLastName.Text; addressData.mobileNo = this.txtPhone.Text; addressData.district = this.txtDistrict.Text; addressData.subDistrict = this.txtSubdistrict.Text; addressData.postalCode = this.txtPostal.Text; addressData.email = this.txtEmail.Text; addressData.userID = this.txtUserName.Text; db.SubmitChanges(); return(true); } else { return(false); } }
private void btnAdd_Click(object sender, EventArgs e) { if (this.checkValidation()) { BloodInventory bloodInvTab = db.BloodInventories.SingleOrDefault(x => x.bloodgroup == this.bloodGroup); if (bloodInvTab != null) { int quantity = int.Parse(this.txtBloodQuantity.Text.ToString()); bloodInvTab.bloodquantity += quantity; db.SubmitChanges(); this.lableStatus.Text = this.bloodGroup + " : " + bloodInvTab.bloodquantity.ToString() + "Total"; } } else { lableStatus.Text = "Validation Error"; } }
private void addToTempTable() { DB_contextDataContext db = new DB_contextDataContext(); UserTempData uTempData = new UserTempData(); uTempData.username = this.LoggedUName; if (this.reqType.Equals("donate")) { uTempData.quantity = 1; uTempData.requestType = "donate"; } else { uTempData.quantity = int.Parse(this.txtBloodQuantity.Text.ToString()); uTempData.requestType = "request"; } db.UserTempDatas.InsertOnSubmit(uTempData); db.SubmitChanges(); MessageBox.Show("Requested For"); }
private void btnConfirm_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(this.txtNewPassword.Text) || !string.IsNullOrEmpty(this.txtConfirmPassword.Text)) { if (this.txtNewPassword.Text.Equals(this.txtConfirmPassword.Text)) { this.newPassData = db.UserLoginDatas.SingleOrDefault(x => x.username == this.uName); if (this.newPassData != null && this.uRoll == newPassData.userroll) { if (this.txtConfirmPassword.Text.Equals(newPassData.password)) { this.LblStatus.Text = "You Have The Same Password Allready"; this.txtNewPassword.Clear(); this.txtConfirmPassword.Clear(); } else { //this.uRoll = newPassData.userroll; //MessageBox.Show("ROLL : " + this.uRoll + " NAME : " + this.newPassData.username + " Pass : "******"Password Changed Successfully"); } } } else { this.LblStatus.Text = "Password Doesn't Match"; this.txtConfirmPassword.Clear(); } } else { this.LblStatus.Text = "Password Field can Not be Empty"; } }