/* * public List<Inbox> filterByReceiverID(int receiver_id){ * List<Inbox> temp = new List<Inbox> (); * for (int i = 0; i < this.inbox.Count; i++) { * if (inbox[i].receiver_id == receiver_id) { * temp.Add(inbox [i]); * } * } * return temp; * } * public List<Inbox> filterBySenderID(int sender_id){ * List<Inbox> temp = new List<Inbox> (); * for (int i = 0; i < this.inbox.Count; i++) { * if (inbox[i].sender_id == sender_id){ * temp.Add(inbox [i]); * } * } * return temp; * } */ #endregion #region database public void insertNewMessageContent(InboxContent ic) { dbh.newConnection(); string sql = "insert inboxContent(message, unread, inbox_id, dateSent) values('" + ic.message + "', " + ic.unread + ", " + ic.inbox_id + ", NOW());"; dbh.ExecuteNonQuery(sql); }
public void loadInboxBasedOnUser(int receiver_id) { //loads user here based on its receiver and sender id //loads data from database dbh.newConnection(); string sql = "select i.id AS id, u.username AS username, i.receiver_id AS receiver_id, i.sender_id AS sender_id, i.subject AS subject, i.dateCreated AS dateCreated" + " FROM user u, inbox i WHERE i.sender_id = u.id AND i.receiver_id = " + receiver_id + " OR i.sender_id = " + receiver_id + " AND u.id = i.receiver_id ORDER BY i.dateCreated desc;"; IDataReader reader = dbh.GetQueryResult(sql); while (reader.Read()) { Inbox newInbox = new Inbox(Convert.ToInt16(reader["id"]), Convert.ToInt16(reader["sender_id"]), "" + reader["username"], "" + reader["subject"], Convert.ToInt16(reader["receiver_id"])); DatabaseHandler dbh2 = new DatabaseHandler(); dbh2.newConnection(); string sql2 = "SELECT id, message, unread, dateSent, inbox_id FROM inboxContent WHERE inbox_id=" + newInbox.id + "; "; IDataReader reader2 = dbh2.GetQueryResult(sql2); while (reader2.Read()) { InboxContent ic = new InboxContent(Convert.ToInt16(reader2["id"]), "" + reader2["message"], (Convert.ToInt16(reader2["unread"]) == 1) ? true : false, "" + reader2["dateSent"], Convert.ToInt16(reader2["inbox_id"])); newInbox.appendInboxContent(ic); } dbh2.CloseConnection(); inbox.Add(newInbox); } }
public void appendInboxContent(InboxContent ic) { this.InboxContent.Add(ic); }
protected void Page_Load(object sender, EventArgs e) { if (UserBLL.CurrentUser == null) { Response.Redirect("portal.ecx.com.et?CMD=logoff"); return; } if (IsPostBack != true) { List <InboxContent> listTaskNameWithCount = null; listTaskNameWithCount = InboxContent.GetListForInbox(); List <InBoxList> list = new List <InBoxList>(); InboxRowGrid os = new InboxRowGrid(); //GRN XMLHelper oGRNXML = new XMLHelper("InboxGRNQueue.xml"); list = os.GetInbox(listTaskNameWithCount, oGRNXML.GetGrantedInBoxItems()); this.gvInbox.DataSource = list; this.gvInbox.DataBind(); //Grade Dispute XMLHelper oGDXML = new XMLHelper("InboxGDQueue.xml"); list = os.GetInbox(listTaskNameWithCount, oGDXML.GetGrantedInBoxItems()); this.gvGradeDispute.DataSource = list; this.gvGradeDispute.DataBind(); //GIN XMLHelper oGINXML = new XMLHelper("InboxGINQueue.xml"); list = os.GetInbox(listTaskNameWithCount, oGINXML.GetGrantedInBoxItems()); this.gvGIn.DataSource = list; this.gvGIn.DataBind(); //ReSampling XMLHelper oInboxRCRSQueueXML = new XMLHelper("InboxRCRSQueue.xml"); list = os.GetInbox(listTaskNameWithCount, oInboxRCRSQueueXML.GetGrantedInBoxItems()); this.gvReSampling.DataSource = list; this.gvReSampling.DataBind(); //Edit Approved GRN XMLHelper oInboxApprovedGRNEditRequestXML = new XMLHelper("InboxApprovedGRNEditRequest.xml"); list = os.GetInbox(listTaskNameWithCount, oInboxApprovedGRNEditRequestXML.GetGrantedInBoxItems()); this.gvRequestToEditApprovedGRN.DataSource = list; this.gvRequestToEditApprovedGRN.DataBind(); //Cancel Approved GRN XMLHelper oInboxCancelApprovedGRNQueueXML = new XMLHelper("InboxCancelApprovedGRNQueue.xml"); list = os.GetInbox(listTaskNameWithCount, oInboxCancelApprovedGRNQueueXML.GetGrantedInBoxItems()); this.gvCancelApprovedGRN.DataSource = list; this.gvCancelApprovedGRN.DataBind(); //GIN Edit XMLHelper oInboxGINEditQueueXML = new XMLHelper("InboxGINEditQueue.xml"); list = os.GetInbox(listTaskNameWithCount, oInboxGINEditQueueXML.GetGrantedInBoxItems()); this.gvGINEdit.DataSource = list; this.gvGINEdit.DataBind(); } }