using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
namespace OmegaLove.Web.UI
{
public partial class ctrlMyMail : OmegaLoveBasePageUserControl
{
public static string ConnnectionString = ConfigurationManager.ConnectionStrings["omegaloveConnectionString"].ToString();
string message = string.Empty;
DataSet ds = null;
DataTable dt = null;
private static string mstrConn = String.Empty;
private static string UserId = null;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
UserId = Session["UserName"] == null ? "default if null" : Session["UserName"].ToString();
if (UserId != null)
{
PopulateMailbox("", "");
}
else
{
Response.Redirect("~/Login.aspx");
}
// singleton oSingleton = singleton.GetCurrentSingleton();
// oSingleton.messagesIDList.Clear();
// SaveCheckedValues();
// LoadSavedCheckValues();
}
}
private void SetSort(string field, bool asc)
{
if (ViewState["SortField"] != null && (string)ViewState["SortField"] == field)
{
ViewState["SortAsc"] = !(bool)ViewState["SortAsc"];
}
else
{
ViewState["SortField"] = field;
ViewState["SortAsc"] = asc;
}
}
private void PopulateMailbox(string SortExpression, string DeleteString)
{
MembershipUser myObject = Membership.GetUser();
int intGetProfileID = 0;
System.Web.Security.MembershipUser mu = System.Web.Security.Membership.GetUser();
string strUsrId = mu.ProviderUserKey.ToString();
UserId = Session["UserName"] == null ? "default if null" : Session["UserName"].ToString();
dt = DataBase.Procedures.prc_Profile_Select.ToDataTable(ConnnectionString, UserId);
intGetProfileID = Convert.ToInt32(dt.Rows[0]["ProfileID"].ToString());
try
{
ds = DataBase.Procedures.prc_Messages_Select.ToDataSet(ConnnectionString, Convert.ToInt32(dt.Rows[0]["ProfileID"].ToString()), strUsrId, DeleteString);
if ((ds != null) && (ds.Tables[0] != null) && (ds.Tables[0].Rows.Count > 0))
{
//LABEL_NoMessages.Text = string.Empty;
gvInbox.AllowPaging = true;
gvInbox.PageSize = 2;
//gvInbox.PagerStyle.Mode = PagerMode.NumericPages;
// Add filter for inbox, drafts, etc.
//gvInbox.DataSource.DefaultView.RowFilter = String.Concat("Station = \'", sStation, "\'");
gvInbox.DataSource = ds.Tables[0].DefaultView;
gvInbox.Visible = true;
gvInbox.DataBind();
}
else
{
gvInbox.Visible = false;
//LABEL_NoMessages.Text = "No Messages";
}
return;
}
catch (SqlException e)
{
WebMsgBox.Show(e.ToString());
}
}
protected void gvInbox_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
}
protected void gvInbox_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
// Add attribute for onclick event on check box in header passing MessageId of Select All checkbox
((CheckBox)e.Row.FindControl("cbSelectAll")).Attributes.Add("onclick", "javascript:SelectAll('" + ((CheckBox)e.Row.FindControl("cbSelectAll")).ClientID + "')");
}
if (e.Row.RowType == DataControlRowType.DataRow)
{
HiddenField hdimageId = (HiddenField)e.Row.FindControl("hiddenImgID");
System.Web.UI.WebControls.Image MainPicID = (System.Web.UI.WebControls.Image)(e.Row.FindControl("MainPicID"));
MainPicID.ID = hdimageId.Value;
MainPicID.ToolTip = "Thumbnail of Photo Number =" + hdimageId.Value;
DataTable dtPhotos = new DataTable();
dtPhotos = DataBase.Procedures.prc_Photos_Select_Primary.ToDataTable(ConnnectionString, Convert.ToInt32(hdimageId.Value));
// Get img id from datatable.
if (((dtPhotos != null) && (dtPhotos.Rows.Count > 0)))
{
if (Convert.ToBoolean(dtPhotos.Rows[0]["p_Primary"]))
{
MainPicID.ImageUrl = "~/Secure/ShowImage.ashx?img_id=" + dtPhotos.Rows[0]["PhotoID"].ToString() + "&" + "imagesize=T" + "&" + "imageisprimary=" + "True" + "'";
}
}
else
{
// set default image
}
}
}
protected void cb1_CheckedChanged(object sender, EventArgs e)
{
// SaveCheckedValues();
}
protected void cbSelectAll_CheckedChanged(object sender, EventArgs e)
{
// SaveCheckedValues();
}
//protected void BtnDelete_Click(object sender, ImageClickEventArgs e)
//{
// int index = -1;
// ImageButton btnDelete = sender as ImageButton;
// GridViewRow row = (GridViewRow)btnDelete.NamingContainer;
// index = (int)gvInbox.DataKeys[row.RowIndex].Value;
// SaveCheckedValues();
// PopulateMailbox("", index.ToString());
// LoadSavedCheckValues();
//}
public static string GetConnectionString(string _connectionStringsName)
{
System.Configuration.ConnectionStringSettingsCollection config = System.Configuration.ConfigurationManager.ConnectionStrings;
for (int i = 0; i < config.Count; i++)
{
if (config[i].Name.Equals(_connectionStringsName, StringComparison.OrdinalIgnoreCase))
return config[i].ToString();
}
return String.Empty;
}
}
}
|