protected void SubmitBtn_Click(object sender, EventArgs e) { AccessDB dbObj = new AccessDB(); dbObj.Open(); dbObj.Query = string.Format("Select emailaddress,CAST( AES_DECRYPT( passwd, 'kalli' ) AS CHAR( 100 ) ) from tbluserlogin where emailaddress ='{1}'", Constants.AESKey, UserNameTbx.Text); dbObj.ExecuteQuery(); if (dbObj.Dataset.Tables[0].Rows.Count > 0) { Mail mailObj = new Mail(); mailObj.To = UserNameTbx.Text; mailObj.Subject = "Reply: Forgot Password Request"; mailObj.MailBody = string.Format("Dear Ma'am/Sir, \r\n Username:{0} \r\n Password:{1} \r\n Regards, \r\n Admin team.", UserNameTbx.Text, dbObj.Dataset.Tables[0].Rows[0][1]); mailObj.SendMailMessage(); VerificationLbl.Text = "Your password has been sent to your email."; VerificationLbl.Visible = true; } else { VerificationLbl.Text = "The UserName provided is not valid.Kindly verify and retry / contact the Admin Team."; VerificationLbl.Visible = true; } dbObj.Close(); }
private void CheckLogin() { string Username = txtUserName.Text; string Password = txtPassword.Text; SqlConnection conn = new AccessDB().get_Conn(); conn.Open(); SqlCommand sqlComm = new SqlCommand("select tbUsers.ID_Catalog, tbUsersCatalogs.ID_Catalog, UserName, Password, tbUsersCatalogs.Hidden, tbUsers.Hidden " + "from tbUsers, tbUsersCatalogs " + "where " + "tbUsers.ID_Catalog = tbUsersCatalogs.ID_Catalog and " + "tbUsersCatalogs.ID_Catalog <> 3 and " + "UserName = '******' and Password = '******' and " + "tbUsersCatalogs.Hidden = 1 and tbUsers.Hidden = 1", conn); SqlDataAdapter da = new SqlDataAdapter(sqlComm); DataTable dt = new DataTable(); da.Fill(dt); try { if (dt.Rows.Count > 0) { Session["username"] = Username; Response.Redirect("BanLamViec.aspx"); Session.RemoveAll(); } conn.Close(); } catch (SqlException ex) { throw ex; } finally { if (sqlComm != null) { sqlComm.Dispose(); } if (conn != null) { conn.Close(); } } }
protected void RegisterButton_Click(object sender, EventArgs e) { AccessDB dbObj = new AccessDB(); dbObj.Open(); //verify if registration record already exists dbObj.Query = string.Format("select userregisterationid from tbluserregisteration where EmailID='{0}'", Email.Text); ; dbObj.ExecuteQuery(); if (dbObj.Dataset.Tables[0].Rows.Count > 0) { ConfirmationLabel.Style.Add("color", "Red"); ConfirmationLabel.Text = string.Format("Sorry! Our system shows an account is already registered with this email -{0}. If you have forgotten your password, use the 'Forgot Password' link to get your password.", Email.Text); ConfirmationLabel.Visible = true; } else { dbObj.Dataset.Reset(); //Insert details into the db dbObj.Query = string.Format(@"insert into tblUserRegisteration (FirstName,LastName,FamilyBranch,BornInto,HomePhone,EmailID,Passwd,Address1,Address2,City,State,Country,Pincode,RegistrationDate) values('{0}','{1}','{2}','{3}','{4}','{5}',AES_ENCRYPT('{6}','{7}'),'{8}','{9}','{10}','{11}','{12}',{13},current_timestamp()); " , FirstName.Text, LastName.Text, FamilyBranch.SelectedValue, rdlConnection.SelectedValue, PhoneNumber.Text, Email.Text, Password.Text, Constants.AESKey, Address1.Text, Address2.Text, CityDitrict.Text, State.Text , Country.Text, int.Parse(PinCode.Text)); dbObj.ExecuteNonQuery(); //Get the current users' userregisterationid dbObj.Dataset.Reset(); dbObj.Query = string.Format("select userregisterationid, registrationDate from tbluserregisteration where EmailID='{0}' and FirstName='{1}' and LastName='{2}'", Email.Text, FirstName.Text, LastName.Text); ; dbObj.ExecuteQuery(); long UserRegID = (long)dbObj.Dataset.Tables[0].Rows[0][0]; DateTime dtReg = (DateTime)dbObj.Dataset.Tables[0].Rows[0][1]; //Mail to admin string mailBody = string.Format(Constants.AdminMailText) + Environment.NewLine + string.Format("\n\nFirstName:{0}\nLastName:{1}\nFamily:{2}\nAddress:{3}\nEmail:{4}\nHomePhone:{5}\nRegisteration Date:{6}" , FirstName.Text, LastName.Text, FamilyBranch.Text, string.Concat(Address1.Text, ",", Address2.Text, ",", CityDitrict.Text, "-", PinCode.Text, ",", State.Text, ",", Country.Text, ","), Email.Text, PhoneNumber.Text, dtReg) + Environment.NewLine + "http://www.Kallivayalil.com/ActivateUser.aspx?UserRegID=" + UserRegID.ToString(); dbObj.Dataset.Reset(); dbObj.Query = string.Format(@"Select emailaddress from tbluserlogin where isadmin=true"); dbObj.ExecuteQuery(); for (int i = 0; i < dbObj.Dataset.Tables[0].Rows.Count; i++) { SendMailMessage(dbObj.Dataset.Tables[0].Rows[i][0].ToString(), "*****@*****.**", mailBody); } //mail to user. mailBody = string.Empty; mailBody = string.Format(Constants.UserMailText) + Environment.NewLine + string.Format("\n\nFirstName:{0}\nLastName:{1}\nFamily:{2}\nAddress:{3}\nEmail:{4}\nHomePhone:{5}\nRegistration Date:{6}" , FirstName.Text, LastName.Text, FamilyBranch.Text, string.Concat(Address1.Text, ",", Address2.Text, ",", CityDitrict.Text, "-", PinCode.Text, ",", State.Text, ",", Country.Text, ","), Email.Text, PhoneNumber.Text, dtReg); SendMailMessage(Email.Text, "RegistrationMail @ Kallivayalil.com", mailBody); ConfirmationLabel.Style.Add("color", "Green"); ConfirmationLabel.Text = "Thank You for registering. A confirmation email has been sent to the emailaddress you provided. We will review your information and your account will be activated at the earliest."; ConfirmationLabel.Visible = true; UserRegistration.Visible = false; } dbObj.Close(); }
private void BindData() { AccessDB dbObj = new AccessDB(); dbObj.Open(); dbObj.Query = string.Format("Select * from tblspecialevents where eventname ={0} and eventdate='{1}'", Session["EventName"], Session["EventDate"]); dbObj.ExecuteQuery(); DetailsView1.DataSource = dbObj.Dataset; DetailsView1.DataBind(); dbObj.Close(); }
public DataSet GetData() { string eventQuery = string.Empty; if (Session["UserLogin"] != null) { eventQuery = "Select eventname, eventdate, eventtype, eventdetails from tblspecialevents "; } else { eventQuery = "Select eventname, eventdate, eventtype, eventdetails from tblspecialevents where IsPublic=1"; } dbObj = new AccessDB(); dbObj.Open(); dbObj.Query = eventQuery; dbObj.ExecuteQuery(); DataSet ds = new DataSet(); DataTable dt = new DataTable("News"); DataRow dr; dt.Columns.Add(new DataColumn("Id", typeof(Int32))); dt.Columns.Add(new DataColumn("Url", typeof(string))); dt.Columns.Add(new DataColumn("Desc", typeof(string))); string eventImage="images/celebration.gif"; string eventTitle = string.Empty; string eventDetails = string.Empty; string eventType = string.Empty; DateTime dtobj = DateTime.Now; for (int i = 0; i < dbObj.Dataset.Tables[0].Rows.Count; i++) { dr = dt.NewRow(); dr[0] = i + 1; dtobj = (DateTime)dbObj.Dataset.Tables[0].Rows[i][1]; eventTitle = String.Format("{0} on {1}/{2}/{3}<br/>", dbObj.Dataset.Tables[0].Rows[i][0], dtobj.Day, dtobj.Month, dtobj.Year); eventDetails = String.Format("<u>Event Details</u>:<br/> {0}", dbObj.Dataset.Tables[0].Rows[i][3]); eventType = dbObj.Dataset.Tables[0].Rows[i][2].ToString(); eventImage=GetEventImage(eventType); dr[1] = string.Format("javascript:openQuickAddDialog(1000, 101, '{0}','{1}','{2}');", eventTitle, eventDetails, eventImage); //dr[1] = string.Format("Event.aspx?EventName={0}&EventDate={3}-{2}-{1}", dbObj.Dataset.Tables[0].Rows[i][0], dtobj.Day, dtobj.Month, dtobj.Year); dr[2] = eventTitle; dt.Rows.Add(dr); } ds.Tables.Add(dt); Session["dt"] = dt; dbObj.Close(); return ds; }
protected void AddEvntBtn_Click(object sender, EventArgs e) { dbObj = new AccessDB(); dbObj.Open(); bool isPublic = false; if (MemOnlyRb.Checked) isPublic = true; dbObj.Query = string.Format(@"insert into tblspecialevents(EventName,EventType,EventDetails,StartDate,EventDate,ContactPerson,ContactNumber,IsPublic,CreatedBy,updatedby,updateddate) values ('{0}','{1}','{2}','{3}','{4}','{5}','{6}',{7},'{8}','{8}',curdate())" , EvntNameTbx.Text, EvntTypeDdl.SelectedValue, EvntDescTbx.Text, Convert.ToDateTime(StartDtTbx.Text).ToString("yyyy-MM-dd hh:mm:ss"), Convert.ToDateTime(EndDtTbx.Text).ToString("yyyy-MM-dd hh:mm:ss"), ContactPersonTbx.Text, ContactNumTbx.Text, isPublic, Session["UserName"]); dbObj.ExecuteNonQuery(); dbObj.Close(); divSuccessLabel.Visible = true; divAddevent.Visible = false; }
protected void btnCrop_Click(object sender, EventArgs e) { try { if (W.Value != string.Empty) { int w = Convert.ToInt32(W.Value); int h = Convert.ToInt32(H.Value); int x = Convert.ToInt32(X.Value); int y = Convert.ToInt32(Y.Value); AccessDB dbObj = new AccessDB(); dbObj.Open(); dbObj.Query = "Select Photo from tblSpouse where spID=?"; dbObj.command.Parameters.Add(new System.Data.Odbc.OdbcParameter("spID", Session["queryID"])); byte[] _buf = (byte[])dbObj.ExecuteScalar(); dbObj.Close(); MemoryStream msOrig = new MemoryStream(_buf); byte[] CropImage = Crop(msOrig, w, h, x, y); using (MemoryStream ms = new MemoryStream(CropImage, 0, CropImage.Length)) { ms.Write(CropImage, 0, CropImage.Length); Byte[] Cropped = ms.ToArray(); AccessDB dbObj1 = new AccessDB(); dbObj1.Open(); dbObj1.Query = "Update tblSpouse SET Photo=? where SpID=?"; dbObj1.command.Parameters.Add(new System.Data.Odbc.OdbcParameter("Photo", Cropped)); dbObj.command.Parameters.Add(new System.Data.Odbc.OdbcParameter("SpID", Session["queryID"])); dbObj1.command.Prepare(); dbObj1.ExecuteNonQuery(); } } } catch (Exception ex) { } finally { pnlCrop.Visible = false; pnlCropped.Visible = true; } }
private void refreshGrid() { DataSet ds = new DataSet(); ds.Tables.Add(new DataTable()); DataTable dt = new DataTable(); dt.Columns.Add("EventName"); dt.Columns.Add("EventType"); dt.Columns.Add("EventDetails"); dt.Columns.Add("EventDate"); dt.Columns.Add("ContactPerson"); dt.Columns.Add("ContactNumber"); AccessDB dbobj = new AccessDB(); dbobj.Open(); //if (d3.Text == string.Empty) // d3.Text = "01.01.2000"; //if (d4.Text == string.Empty) // d4.Text = "12.31.2030"; string whereclause = string.Empty; if (d3.Text != string.Empty && d4.Text != string.Empty) whereclause = string.Format(" where eventdate between STR_TO_DATE('{0}','%M %d, %Y') and STR_TO_DATE('{1}','%M %d, %Y')", d3.Text, d4.Text); dbobj.Dataset.Reset(); dbobj.Query = string.Format("Select SocialEventID,eventname as EventName,eventtype as EventType,eventdetails as EventDetails,startdate as StartDate,DATE_FORMAT(eventdate, '%a %d %b, %Y') as EventDate,contactperson as ContactPerson,contactnumber as ContactNumber,ispublic,updatedby,DATE_FORMAT(updateddate,'%d/%m/%y') as updateddate from tblspecialevents" + whereclause); dbobj.ExecuteQuery(); for (int i = 0; i < dbobj.Dataset.Tables[0].Rows.Count; i++) { dt.ImportRow(dbobj.Dataset.Tables[0].Rows[i]); } GridView1.DataSource = dt; GridView1.DataBind(); dbobj.Close(); }
protected void Page_Load(object sender, EventArgs e) { string UserName = (string)Session["UserLogin"]; if (UserName == null) { Session.Add("PageToLoad", "http://www.kallivayalil.com/Kallivayalil/LinkProfile.aspx"); Response.Redirect("default.aspx"); } if (Session["SelectedProfileID"] == null) { ProfileDetailslbl.Visible = false; RadioButtonList1.Visible = false; NewUserLbl.ForeColor = Color.Green; NewUserLbl.Visible = true; } else { if (Session["Borninto"].ToString() == "B") { dbObj = new AccessDB(); dbObj.Dataset.Reset(); dbObj.Query = string.Format(@"SELECT tbluserprofile.UserProfileID,Salutation, FirstName, MiddleName, LastName, PreferredName, Gender, FamilyBranch, HouseName, BornOn, MaritalStatus, Occupation, Employer, AlternateEmailAddress, Address1,Address2, City, State, Pincode, Country, HomePhone, MobilePhone, Website FROM tbluserprofile WHERE ((UserProfileID = {0}) and IsActive!=1)", Session["SelectedProfileID"]); dbObj.ExecuteQuery(); DetailsView2.DataSource = dbObj.Dataset.Tables[0]; DetailsView2.DataBind(); dbObj.Close(); } else { dbObj = new AccessDB(); dbObj.Dataset.Reset(); dbObj.Query = string.Format(@"SELECT tblspouse.spid,tblspouse.Salutation, tblspouse.FirstName, tblspouse.LastName, tblspouse.PreferredName, tblspouse.Gender, tblspouse.Familyname, tblspouse.BornOn, tbluserprofile.City, tbluserprofile.State, tbluserprofile.Pincode, tbluserprofile.Country, tbluserprofile.mobilePhone FROM tblspouse,tbluserprofile WHERE ((spid = {0}) and tblspouse.IsActive!=1)", Session["SelectedProfileID"]); dbObj.ExecuteQuery(); DetailsView2.DataSource = dbObj.Dataset.Tables[0]; DetailsView2.DataBind(); dbObj.Close(); } } }
protected void LoginButton_Click(object sender, ImageClickEventArgs e) { AccessDB dbObj = new AccessDB(); string userName = string.Empty; string paswd = string.Empty; //Retrieving the Username and Password entered by the user. userName = Login1.UserName; paswd = Login1.Password; dbObj.Open(); dbObj.Query = string.Format("Select * from tbluserlogin where EmailAddress='{0}' and Passwd=AES_ENCRYPT('{1}','{2}')" , userName, paswd,Constants.AESKey); dbObj.ExecuteQuery(); if (dbObj.Dataset.Tables[0].Rows.Count > 0) { //Username and pasword exists for this user. Session.Add("UserLogin", userName); Session.Add("ID", dbObj.Dataset.Tables[0].Rows[0]["UserProfileID"]); Session.Add("IsAdmin", dbObj.Dataset.Tables[0].Rows[0][7]); Session.Add("PType", dbObj.Dataset.Tables[0].Rows[0]["ProfileType"]); dbObj.Dataset.Clear(); dbObj.Close(); dbObj.Query = string.Format("Select * from tbluserprofile where UserProfileID={0}", Session["ID"]); dbObj.ExecuteQuery(); if (dbObj.Dataset.Tables[0].Rows.Count > 0) { Session.Add("UserName", dbObj.Dataset.Tables[0].Rows[0]["FirstName"] + " " + dbObj.Dataset.Tables[0].Rows[0]["LastName"]); } if (Session["PageToLoad"] != null) { Response.Redirect(Session["PageToLoad"].ToString()); Session.Remove("PageToLoad"); } else Response.Redirect("Default.aspx"); } else { dbObj.Query = string.Format("Select * from tbluserlogin where EmailAddress='{0}'", userName); dbObj.ExecuteQuery(); if (dbObj.Dataset.Tables[0].Rows.Count > 0) { //Username exists but not activated. dbObj.Dataset.Clear(); dbObj.Close(); Login1.FailureText = "Login Failed. Incorrect Login Information."; Login1.FailureAction = LoginFailureAction.Refresh; } else { dbObj.Query = string.Format("Select * from tbluserregisteration where EmailId='{0}'", userName); dbObj.ExecuteQuery(); if (dbObj.Dataset.Tables[0].Rows.Count > 0) { //Username exists but not activated. dbObj.Dataset.Clear(); dbObj.Close(); Login1.FailureText = "Your account has not been activated by the Administrator. Sorry for the delay."; Login1.FailureAction = LoginFailureAction.Refresh; } else { Login1.FailureText = "Invalid User Name and Password."; Login1.FailureAction = LoginFailureAction.Refresh; } } } }
protected void btnUpload_Click(object sender, EventArgs e) { Boolean FileOK = false; Boolean FileSaved = false; if (FileUpload1.HasFile) { Session["WorkingImage"] = FileUpload1.FileName; String FileExtension = Path.GetExtension(Session["WorkingImage"].ToString()).ToLower(); String[] allowedExtensions = { ".png", ".jpeg", ".jpg", ".gif" }; for (int i = 0; i < allowedExtensions.Length; i++) { if (FileExtension == allowedExtensions[i]) { FileOK = true; } } } if (FileOK) { try { Byte[] file = FileUpload1.FileBytes; AccessDB dbObj = new AccessDB(); dbObj.Open(); dbObj.Query = "Update tblUserProfile SET Photo=? where UserProfileID=?"; dbObj.command.Parameters.Add(new System.Data.Odbc.OdbcParameter("Photo", file)); dbObj.command.Parameters.Add(new System.Data.Odbc.OdbcParameter("UserProfileID", Session["ID"])); dbObj.command.Prepare(); dbObj.ExecuteNonQuery(); dbObj.Close(); FileSaved = true; } catch (Exception ex) { lblError.Text = "File could not be uploaded." + ex.Message.ToString(); lblError.Visible = true; FileSaved = false; } } else { lblError.Text = "Cannot accept files of this type."; lblError.Visible = true; } if (FileSaved) { pnlUpload.Visible = false; pnlCrop.Visible = true; pnlCropped.Visible = false; } }