using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data.SqlClient;
///
/// Summary description for Clsmilitary
///
public class Clsmilitary
{
public Clsmilitary()
{
//
// TODO: Add constructor logic here
//
}
#region fields
private Int32 _mid,_comid;
private int _userid;
private string _comment;
private DateTime _commenteddate;
private int _approve;
private string _title;
private string _news;
private string _name;
private DateTime _posteddate;
private int _enablecomments;
#endregion
#region Public Properties
public Int32 Comid
{
get { return _comid; }
set { _comid = value; }
}
public Int32 Userid
{
get { return _userid; }
set { _userid = value; }
}
public string Comment
{
get { return _comment; }
set { _comment = value; }
}
public DateTime Commeteddate
{
get { return _commenteddate; }
set { _commenteddate = value; }
}
public int Approve
{
get { return _approve; }
set { _approve = value; }
}
public Int32 Mid
{
get { return _mid; }
set { _mid = value; }
}
public string Title
{
get { return _title; }
set { _title = value; }
}
public string Name
{
get { return _name ; }
set { _name = value; }
}
public string News
{
get { return _news; }
set { _news = value; }
}
public DateTime PostedDate
{
get { return _posteddate; }
set { _posteddate = value; }
}
public int EnableComments
{
get { return _enablecomments; }
set { _enablecomments = value; }
}
#endregion
#region methods
public int DeleteMilitaryNewsById()
{
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@mid", SqlDbType.BigInt));
cmd.Parameters["@mid"].Value = this._mid;
SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "Sp_Delete_MilitaryNewsById");
return 1;
}
catch
{
return 0;
}
}
public DataSet GetMilitaryNewsbyId()
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@mid", SqlDbType.BigInt));
cmd.Parameters["@mid"].Value = this._mid;
return SQLHelper.ExecuteAdapter(cmd, CommandType.StoredProcedure, "GetmilitarynewsById");
}
public int UpdateMilitaryNews()
{
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@exists", SqlDbType.Int));
cmd.Parameters["@Exists"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(new SqlParameter("@mid", SqlDbType.BigInt));
cmd.Parameters["@mid"].Value = this._mid ;
cmd.Parameters.Add(new SqlParameter("@title", SqlDbType.NVarChar, 50));
cmd.Parameters["@title"].Value = this._title;
cmd.Parameters.Add(new SqlParameter("@news", SqlDbType.NVarChar));
cmd.Parameters["@news"].Value = this._news;
cmd.Parameters.Add(new SqlParameter("@enablecomments", SqlDbType.NVarChar));
cmd.Parameters["@enablecomments"].Value = this._enablecomments;
SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "UpdateMilitaryNews");
return nvlint(cmd.Parameters["@exists"].Value);
}
catch
{
return 1;
}
}
public int InsertMilitaryNews()
{
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@exists", SqlDbType.Int));
cmd.Parameters["@Exists"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(new SqlParameter("@title", SqlDbType.NVarChar, 50));
cmd.Parameters["@title"].Value = this._title;
cmd.Parameters.Add(new SqlParameter("@news", SqlDbType.NVarChar));
cmd.Parameters["@news"].Value = this._news;
cmd.Parameters.Add(new SqlParameter("@enablecomments", SqlDbType.NVarChar));
cmd.Parameters["@enablecomments"].Value = this._enablecomments;
SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "InsertMilitaryNews");
return nvlint(cmd.Parameters["@exists"].Value);
}
catch
{
return 1;
}
}
public int InsertComments()
{
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@exists", SqlDbType.Int));
cmd.Parameters["@Exists"].Direction = ParameterDirection.Output;
cmd.Parameters.Add(new SqlParameter("@mid", SqlDbType.BigInt));
cmd.Parameters["@mid"].Value = this._mid;
cmd.Parameters.Add(new SqlParameter("@userid", SqlDbType.Int));
cmd.Parameters["@userid"].Value = this._userid;
cmd.Parameters.Add(new SqlParameter("@comment", SqlDbType.NVarChar,250));
cmd.Parameters["@comment"].Value = this._comment;
SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "InsertComments");
return nvlint(cmd.Parameters["@exists"].Value);
}
catch
{
return 0;
}
}
//GetAllComments
public DataSet GetAllComments()
{
SqlCommand cmd = new SqlCommand();
//@name
cmd.Parameters.Add(new SqlParameter("@mid", SqlDbType.BigInt));
cmd.Parameters["@mid"].Value = this._mid;
cmd.Parameters.Add(new SqlParameter("@name", SqlDbType.NVarChar ,50));
cmd.Parameters["@name"].Value = this._name;
return SQLHelper.ExecuteAdapter(cmd, CommandType.StoredProcedure, "GetAllComments");
}
public DataSet GetCommentsByNewsId()
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@mid", SqlDbType.BigInt));
cmd.Parameters["@mid"].Value = this._mid;
return SQLHelper.ExecuteAdapter(cmd, CommandType.StoredProcedure, "GetCommentsByNewsID");
}
public DataSet GetMilitaryNews()
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@name", SqlDbType.VarChar, 50));
cmd.Parameters["@name"].Value = this._name;
return SQLHelper.ExecuteAdapter(cmd, CommandType.StoredProcedure, "GetAllMilitaryNews");
}
public static int nvlint(object inval)
{
if (inval == DBNull.Value)
{
return 0;
}
return Convert.ToInt32(inval);
}
public int DeleteCommentsById()
{
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@comid", SqlDbType.BigInt));
cmd.Parameters["@comid"].Value = this._comid;
SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "Sp_Delete_CommentsByID");
return 1;
}
catch
{
return 0;
}
}
//ApproveComments
public int ApproveComments()
{
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@comid", SqlDbType.BigInt));
cmd.Parameters["@comid"].Value = this._comid;
SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "ApproveComments");
return 1;
}
catch
{
return 0;
}
}
public int DeleteMilitaryNews()
{
try
{
SqlCommand cmd = new SqlCommand();
cmd.Parameters.Add(new SqlParameter("@mid", SqlDbType.BigInt));
cmd.Parameters["@mid"].Value = this._mid ;
SQLHelper.ExecuteNonQuery(cmd, CommandType.StoredProcedure, "Sp_Delete_MilitaryNews");
return 1;
}
catch
{
return 0;
}
}
#endregion
}