using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using CRM.Lib.DAL;
namespace CRM.Lib
{
public class Helpdesk
{
#region CONSTRUCTOR
public Helpdesk()
{
this.init();
}
public void init()
{
this.ID = 0;
this.LastName = "";
this.FirstName = "";
this.MiddleName = "";
this.VIPNo = "";
this.ContactNo = "";
this.Email = "";
this.Details = "";
this.Branch = "";
this.AssignedStaff = "";
this.StatusType = 0;
this.RequestDate = DateTime.Now;
this.RequestTime = DateTime.Now;
this.Solution = "";
this.Discontinued = 0;
this.CreatedBy = "";
this.CreatedDate = DateTime.Now;
this.LastModifiedBy = "";
this.LastModifiedDate = DateTime.Now;
}
#endregion
#region Properties
public int ID { get; set; }
public string CustomerName {
get { return this.FirstName + " " + this.MiddleName + " " + this.LastName; }
}
public string LastName { get; set; }
public string FirstName { get; set; }
public string MiddleName { get; set; }
public string VIPNo { get; set; }
public string ContactNo { get; set; }
public string Email { get; set; }
public string Details { get; set; }
public string Branch { get; set; }
public string AssignedStaff { get; set; }
public int StatusType { get; set; }
public string Status {
get { return CRM.Lib.StatusType.GetById(this.StatusType).Status.ToString(); }
}
public DateTime RequestDate { get; set; }
public DateTime RequestTime { get; set; }
public string Solution { get; set; }
public int Discontinued { get; set; }
public string CreatedBy { get; set; }
public DateTime CreatedDate { get; set; }
public string LastModifiedBy { get; set; }
public DateTime LastModifiedDate { get; set; }
#endregion
#region Public Methods
public static Helpdesk GetById(int id)
{
var dal = new HelpdeskDAL();
var instance = new Helpdesk();
instance.Bind(dal.GetById(id));
return instance;
}
public static List GetAll()
{
var dal = new HelpdeskDAL();
var collection = new List();
foreach (DataRow row in dal.GetAll().Rows)
{
var instance = new Helpdesk();
instance.Bind(row);
collection.Add(instance);
}
return collection;
}
public static List GetByStaffId(string id)
{
var dal = new HelpdeskDAL();
var collection = new List();
foreach (DataRow row in dal.GetByStaffId(id).Rows)
{
var instance = new Helpdesk();
instance.Bind(row);
collection.Add(instance);
}
return collection;
}
public void Bind(DataRow row)
{
if (row != null)
{
this.ID = Convert.ToInt32(row["ID"]);
this.LastName = Convert.ToString(row["LastName"]);
this.FirstName = Convert.ToString(row["FirstName"]);
this.MiddleName = Convert.ToString(row["MiddleName"]);
this.VIPNo = Convert.ToString(row["VIPNo"]);
this.ContactNo = Convert.ToString(row["ContactNo"]);
this.Email = Convert.ToString(row["Email"]);
this.Details = Convert.ToString(row["Details"]);
this.Branch = Convert.ToString(row["Branch"]);
this.AssignedStaff = Convert.ToString(row["AssignedStaff"]);
this.StatusType = Convert.ToInt32(row["StatusType"]);
this.RequestDate = Convert.ToDateTime(row["RequestDate"]);
this.RequestTime = Convert.ToDateTime(row["RequestTime"]);
this.Solution = Convert.ToString(row["Solution"]);
this.Discontinued = Convert.ToInt32(row["Discontinued"]);
this.CreatedBy = Convert.ToString(row["CreatedBy"]);
this.CreatedDate = Convert.ToDateTime(row["CreatedDate"]);
this.LastModifiedBy = Convert.ToString(row["LastModifiedBy"]);
if (!DBNull.Value.Equals(row["LastModifiedDate"]))
this.LastModifiedDate = Convert.ToDateTime(row["LastModifiedDate"]);
}
}
public bool Save()
{
var dal = new HelpdeskDAL();
string message = "";
int ret = dal.Save(this.ID, this.CustomerName,this.LastName,this.FirstName,this.MiddleName, this.VIPNo, this.ContactNo, this.Email, this.Details, this.Branch, this.AssignedStaff, this.StatusType, this.RequestDate, this.RequestTime, this.Solution, this.Discontinued, this.CreatedBy, this.CreatedDate, this.LastModifiedBy, this.LastModifiedDate, out message);
this.ID = ret;
return (ret > 0);
}
public bool Delete()
{
var dal = new HelpdeskDAL();
bool ret = dal.Delete(this.ID);
return ret;
}
#endregion
}
}
Sunday, March 6, 2011
BLL code c#
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment