Esempio n. 1
0
 public List<Maticsoft.Model.Members.SiteMessageLog> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.Members.SiteMessageLog> list = new List<Maticsoft.Model.Members.SiteMessageLog>();
     int count = dt.Rows.Count;
     if (count > 0)
     {
         for (int i = 0; i < count; i++)
         {
             Maticsoft.Model.Members.SiteMessageLog item = new Maticsoft.Model.Members.SiteMessageLog();
             if ((dt.Rows[i]["ID"] != null) && (dt.Rows[i]["ID"].ToString() != ""))
             {
                 item.ID = int.Parse(dt.Rows[i]["ID"].ToString());
             }
             if ((dt.Rows[i]["MessageID"] != null) && (dt.Rows[i]["MessageID"].ToString() != ""))
             {
                 item.MessageID = new int?(int.Parse(dt.Rows[i]["MessageID"].ToString()));
             }
             if ((dt.Rows[i]["MessageType"] != null) && (dt.Rows[i]["MessageType"].ToString() != ""))
             {
                 item.MessageType = dt.Rows[i]["MessageType"].ToString();
             }
             if ((dt.Rows[i]["MessageState"] != null) && (dt.Rows[i]["MessageState"].ToString() != ""))
             {
                 item.MessageState = dt.Rows[i]["MessageState"].ToString();
             }
             if ((dt.Rows[i]["ReceiverID"] != null) && (dt.Rows[i]["ReceiverID"].ToString() != ""))
             {
                 item.ReceiverID = new int?(int.Parse(dt.Rows[i]["ReceiverID"].ToString()));
             }
             if ((dt.Rows[i]["Ext1"] != null) && (dt.Rows[i]["Ext1"].ToString() != ""))
             {
                 item.Ext1 = dt.Rows[i]["Ext1"].ToString();
             }
             if ((dt.Rows[i]["Ext2"] != null) && (dt.Rows[i]["Ext2"].ToString() != ""))
             {
                 item.Ext2 = dt.Rows[i]["Ext2"].ToString();
             }
             if ((dt.Rows[i]["ReceiverUserName"] != null) && (dt.Rows[i]["ReceiverUserName"].ToString() != ""))
             {
                 item.ReceiverUserName = dt.Rows[i]["ReceiverUserName"].ToString();
             }
             list.Add(item);
         }
     }
     return list;
 }
Esempio n. 2
0
 public Maticsoft.Model.Members.SiteMessageLog GetModel(int ID)
 {
     StringBuilder builder = new StringBuilder();
     builder.Append("select  top 1 ID,MessageID,MessageType,MessageState,ReceiverID,Ext1,Ext2,ReceiverUserName from SA_SiteMessageLog ");
     builder.Append(" where ID=@ID");
     SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@ID", SqlDbType.Int, 4) };
     cmdParms[0].Value = ID;
     Maticsoft.Model.Members.SiteMessageLog log = new Maticsoft.Model.Members.SiteMessageLog();
     DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
     if (set.Tables[0].Rows.Count <= 0)
     {
         return null;
     }
     if ((set.Tables[0].Rows[0]["ID"] != null) && (set.Tables[0].Rows[0]["ID"].ToString() != ""))
     {
         log.ID = int.Parse(set.Tables[0].Rows[0]["ID"].ToString());
     }
     if ((set.Tables[0].Rows[0]["MessageID"] != null) && (set.Tables[0].Rows[0]["MessageID"].ToString() != ""))
     {
         log.MessageID = new int?(int.Parse(set.Tables[0].Rows[0]["MessageID"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["MessageType"] != null) && (set.Tables[0].Rows[0]["MessageType"].ToString() != ""))
     {
         log.MessageType = set.Tables[0].Rows[0]["MessageType"].ToString();
     }
     if ((set.Tables[0].Rows[0]["MessageState"] != null) && (set.Tables[0].Rows[0]["MessageState"].ToString() != ""))
     {
         log.MessageState = set.Tables[0].Rows[0]["MessageState"].ToString();
     }
     if ((set.Tables[0].Rows[0]["ReceiverID"] != null) && (set.Tables[0].Rows[0]["ReceiverID"].ToString() != ""))
     {
         log.ReceiverID = new int?(int.Parse(set.Tables[0].Rows[0]["ReceiverID"].ToString()));
     }
     if ((set.Tables[0].Rows[0]["Ext1"] != null) && (set.Tables[0].Rows[0]["Ext1"].ToString() != ""))
     {
         log.Ext1 = set.Tables[0].Rows[0]["Ext1"].ToString();
     }
     if ((set.Tables[0].Rows[0]["Ext2"] != null) && (set.Tables[0].Rows[0]["Ext2"].ToString() != ""))
     {
         log.Ext2 = set.Tables[0].Rows[0]["Ext2"].ToString();
     }
     if ((set.Tables[0].Rows[0]["ReceiverUserName"] != null) && (set.Tables[0].Rows[0]["ReceiverUserName"].ToString() != ""))
     {
         log.ReceiverUserName = set.Tables[0].Rows[0]["ReceiverUserName"].ToString();
     }
     return log;
 }