Sunday, March 6, 2011

DAL code c#

using System;
using System.Data;
using System.Data.SqlClient;

namespace CRM.Lib.DAL
{
    internal class HelpdeskActionDAL : BaseDAL
    {

        public DataTable GetAll()
        {
            base.com.CommandText = "spHelpdeskAction";
            base.com.Parameters.AddWithValue("@id", 0);
            return base.GetDataTable();

        }

        public DataRow GetById(int id)
        {
            base.com.CommandText = "spHelpdeskAction";
            base.com.Parameters.AddWithValue("@id", id);
            return base.GetFirstRow();
        }

        public int Save(int id, int helpdeskid, string actionspecifics, string actionby, string resultspecifics, DateTime actiondate, string endorsedto, DateTime endorseddate, DateTime daterecorded, string createdby, DateTime createddate, string modifiedby, DateTime modifieddate, out string message)
        {
            message = "";
            base.com.CommandText = "spHelpdeskActionUpdate";
            base.com.Parameters.AddWithValue("@id", id);
            base.com.Parameters.AddWithValue("@helpdeskid", helpdeskid);
            base.com.Parameters.AddWithValue("@actionspecifics", actionspecifics);
            base.com.Parameters.AddWithValue("@actionby", actionby);
            base.com.Parameters.AddWithValue("@resultspecifics", resultspecifics);
            base.com.Parameters.AddWithValue("@actiondate", actiondate);
            base.com.Parameters.AddWithValue("@endorsedto", endorsedto);
            base.com.Parameters.AddWithValue("@endorseddate", endorseddate);
            base.com.Parameters.AddWithValue("@daterecorded", daterecorded);
            base.com.Parameters.AddWithValue("@createdby", createdby);
            base.com.Parameters.AddWithValue("@createddate", createddate);
            base.com.Parameters.AddWithValue("@modifiedby", modifiedby);
            base.com.Parameters.AddWithValue("@modifieddate", modifieddate);


            int ra = 0;
            try
            {
                ra = Convert.ToInt32(base.com.ExecuteScalar());
            }
            catch (SqlException sqlex)
            {
                switch (sqlex.Number)
                {
                    case 2601:
                        message = "HelpdeskAction Name already exists!";
                        break;
                    default:
                        message = "Update failed!";
                        break;
                }
            }
            return ra;
        }

        public bool Delete(int id)
        {
            base.com.CommandText = "spHelpdeskActionDelete";
            base.com.Parameters.AddWithValue("@id", id);

            int ra;
            try
            {
                ra = Convert.ToInt32(base.com.ExecuteScalar());
            }
            catch
            {
                throw new Exception("Delete helpdeskaction failed!");
            }
            return (ra > 0);
        }

    }
}


BLL code c#

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
    }
}


my css templates

   .Main
{
 background-color:#6591CD;
 background-image:url(images/DataEntry/splitter_bg.gif);
 background-position:left top;
 background-repeat:repeat-x;
 margin-left:0;
 margin-top:0;
}

.pageHeader
{
 background-image:url(images/TitlebarBackground.png);
 font-family: tahoma, verdana;
 font-size: 11px;
 height: 50px;
 font-weight:bold;
 color: #15428B;
}
.pageFooter
{
 background-image:url(images/Footer1.png);
 height: 50px;
}
.pagePanel
{
 background-image:url(images/ToolBar/GroupBackground.png);
 height: 82px;
 top: 40px; 
 left: 5px; 
 width: 500px;
}
.quickAccess
{
 background-image:url(images/QuickAccess/Background.gif);
 width:100px;
}
.tabStrip
{
 background-image:url(images/ToolBar/Background.gif);
 
}
.accordionHeader
{
    border: 1px solid #3399FF;
    color: white;
    background-color: #2E4d7B;
    background-image:url(images/item_bg.gif);
 font-family: tahoma, verdana;
 font-size: 11px;
 font-weight: bold;
    padding: 9px;
    margin-top: 1px;
    cursor: pointer;
    text-decoration: none;
}
.accordionHeader a
{
 text-decoration: none;
}
.accordionContent
{
    background-color: #FFFFFF;
    border: 1px solid #3399FF;
    font-family: tahoma, verdana;
 font-size: 11px;
    border-top: none;
    padding: 5px;
    padding-top: 1px;
    padding-left:1px;
    padding-bottom:1px;
    cursor: pointer;
}

.accordionHeaderSelected
{
 border: 1px solid #3399FF;
    color: white;
    background-color: #2E4d7B;
    background-image:url(images/item_expanded_bg.gif);
 font-family: tahoma, verdana;
 font-size: 11px;
 font-weight: bold;
 text-decoration: none;
    padding: 9px;
    margin-top: 1px;
    cursor: pointer;
}
.accordionHeaderSelected a
{
 text-decoration: none;
}
.tableMenu a
{
 width:100%;
 background-color: #FFFFFF;
 text-align: left;
 display:block;
 text-decoration: none;
 font-family:Tahoma,verdana;
 font-size :11px;
 color:Black;
 padding:7px;
}
.tableMenu a:hover
{
 text-decoration: none;
 background-color: #E1EAF7;
 color: black;
}
.tableMenu a:selected
{
 text-decoration: none;
 background-color: #E1EAF7;
 color: black;
 font-weight:bold;
}

.popupMenu a
{
 width:100%;
 background-color: #FFFFFF;
 text-align: left;
 display:block;
 text-decoration: none;
 font-family:Tahoma,verdana;
 font-size :11px;
 color:Black;
 padding:5px;
}
.popupMenu a:hover
{
 text-decoration: none;
 background-color: #E1EAF7;
 color: black;
}
.popupMenu a:selected
{
 text-decoration: none;
 background-color: #E1EAF7;
 color: black;
 font-weight:bold;
}

.DataEntry
{
 font-family:Tahoma,verdana;
 font-size :11px;
 border:thin solid #FFFFFF;
}
.dataEntryHeader
{
 background-color: #BFDBFF;
 padding:5px;
 font-weight:bold;
 color: #15428B;
}
.toolBar
{
 background-image:url('images/DataEntry/bg.gif');
 background-color: #BFDBFF;
 width: 100%;
}

.moduleEntry
{
 background-color: #BFDBFF;
 font-family:Arial,Tahoma,Verdana;
 font-size:11px;
 color: #15428B;
}

.moduletabEntry
{
 font-family:Arial,Tahoma,Verdana;
 font-size:11px;
 color: #15428B;
}
.moduleAccess
{
 font-family:Arial,Tahoma,Verdana;
 font-size:11px;
}
.tabgroupBackGround
{
 background-color: #BFDBFF;
 font-family:Arial,Tahoma,Verdana;
 font-size:11px;
 color: #15428B;
 border:thin solid #587fb2;
}
.groupEntry
{
 background-color: #BFDBFF;
 border:solid thin #587fb2;
}

.gray .ajax__tab_header 
{
    font-family:Tahoma,Arial, Sans-Serif;
    background:url(images/tab/tab-line.png) repeat-x bottom;
    font-size:11px;
    font-weight:bold;
    display:block;
}
.gray .ajax__tab_header .ajax__tab_outer 
{
    background:url(images/tab/tab.png) no-repeat left top;
    border-color:#222;
    color:#222;
    padding-left:10px;
    margin-right:3px;
}
.gray .ajax__tab_header .ajax__tab_inner 
{
    background:url(images/tab/tab.png) no-repeat right top;
    border-color:#666;
    color:#666;
    padding:3px 10px 2px 0px;
}
.gray .ajax__tab_hover .ajax__tab_inner 
{
    color:#000;
}
.gray .ajax__tab_active .ajax__tab_outer 
{
    background:url(images/tab/tab.png) no-repeat 0pt -40px;
    border-bottom-color:#ffffff;
}
.gray .ajax__tab_active .ajax__tab_inner 
{
    background:url(images/tab/tab.png) no-repeat right -40px;
    color:#000;
    border-color:#333
}
.gray .ajax__tab_body 
{
    font-family:tahoma,verdana,helvetica;
    font-size:10pt;
    background-color:#DDEAFC;
    border:solid 1px #d7d7d7;
    border-top-width:0;
}

.Grid 
{ 
  padding: 3px; 
  padding-top: 2px; 
  padding-bottom: 1px; 
  border-bottom: 1px solid #E3EFFF; 
  font-family: Arial,Tahoma;
  font-size: 11px;
  color: #000000;
  background-color: #ffffff;
  cursor: pointer;
  border: 1px solid #3399FF; 
}

.Grid tr.normal
{
 color: black;
 background-color: #ffffff;
}

.Grid tr.alternate
{
 color: black;
 background-color: #ffffff;
}

.Grid tr.normal:hover, .Grid tr.alternate:hover
{
 background-color: #e5f1fb;
 color: black;
 font-weight: bold;
}
.GridHeadingRow 
{ 
  
  background-image: url(images/Grid/header1stCell_bg.gif);   
  font-family: Arial,Tahoma;
  font-size: 11px;
  font-weight:normal;
  padding:5px;
}

.LoginHeader
{
 background-image: url(images/Grid/header1stCell_bg.gif);  
 padding:5px;
 font-weight:bold;
 color: #15428B;
 
}

.SelectLink 
{
 display:none;
 width:0px;
}
.Paging
{
 background-color:#FFF;
 font-family: Arial,Tahoma;
 font-size: 11px;
}

.validatorCalloutHighlight
{
    background-color: lemonchiffon;
}


/*Textbox Watermark*/

.unwatermarked {
 height:18px;
 width:148px;
}

.watermarked {
 height:20px;
 width:150px;
 padding:2px 0 0 2px;
 border:1px solid #BEBEBE;
 background-color:#F0F8FF;
 font-family: Arial,Tahoma;
 font-size: 11px;
 color:Gray;
}

.pnlPopupContainer
{
    
    background-repeat: repeat;
    padding: 10px;
    width: 600px;
}

.pnlPopupContainer > div
{
    background-color:White;
    padding: 10px;
    border: 1px solid #FF0000;
    background-repeat: repeat;
}

.msg_button_class
{
   background-image: url(MsgBox/msg_button_1.jpg);
   font-family:Tahoma;
   font-size:11px;
   font-weight:bold;
   color:#FFFFFF;
   border:1px solid #DDDDDD;
   height:22px;
}
.progressBackgroundFilter {
  position:absolute;
  top:0px;
  bottom:0px;
  left:0px;
  right:0px;
  overflow:hidden;
  padding:0;
  margin:0;
  background-color:#000; 
  filter:alpha(opacity=50);
  opacity:0.5;
  z-index:1000;
}
.processMessage { 
  position:absolute; 
  top:30%; 
  left:43%;
  padding:10px;
  height:5%;
  width:14%;
  z-index:1001;
  background-color:#fff;
  font-family: tahoma, verdana;
  font-size: 11px;
  font-weight: bold;
}

.multiCombo
{
 color:Black;
 border:thin solid #587fb2;
 
 font-family:Tahoma,verdana;
 font-size :11px;

}