public int CreateTask(Entity.Task tsk)
        {
            int          retVal = 0;
            SqlParameter parm;

            try {
                using (SqlCommand cmd = new SqlCommand("Isp_CreateTask", _dbConn)) {
                    cmd.CommandType = CommandType.StoredProcedure;
                    parm            = new SqlParameter("@TaskCategoryId", SqlDbType.Int);
                    cmd.Parameters.Add(parm);
                    parm.Value = tsk.CategoryId;

                    parm = new SqlParameter("@TaskName", SqlDbType.VarChar);
                    cmd.Parameters.Add(parm);
                    parm.Value = tsk.TaskName;

                    parm = new SqlParameter("@BudgetHours", SqlDbType.Int);
                    cmd.Parameters.Add(parm);
                    parm.Value = tsk.BudgetHours;

                    parm = new SqlParameter("@ActualHours", SqlDbType.Int);
                    cmd.Parameters.Add(parm);
                    parm.Value = tsk.ActualHours;

                    parm = new SqlParameter("@StartDate", SqlDbType.NChar);
                    cmd.Parameters.Add(parm);
                    parm.Value = tsk.StartDate;

                    parm = new SqlParameter("@EndDate", SqlDbType.NChar);
                    cmd.Parameters.Add(parm);
                    if (String.IsNullOrEmpty(tsk.EndDate))
                    {
                        parm.Value = DBNull.Value;
                    }
                    else
                    {
                        parm.Value = tsk.EndDate;
                    }

                    parm = new SqlParameter("@NewIdentity", SqlDbType.Int);
                    cmd.Parameters.Add(parm);
                    parm.Value = 0;

                    retVal = (Int32)cmd.ExecuteScalar();
                }
            }
            catch (Exception ex) {
                string errTitle = System.Reflection.MethodBase.GetCurrentMethod().Name;
                LogHardErrorMessage(errTitle, ex.Source, ex.Message);
                throw;
            }
            return(retVal);
        }
        public List <Entity.Task> GetAllTasks()
        {
            //SqlParameter parm;
            List <Entity.Task> tasks = new List <Entity.Task>();

            try
            {
                using (SqlCommand cmd = new SqlCommand("Gsp_GetAllTasks", _dbConn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Entity.Task et = new Entity.Task();
                        et.CategoryId   = Convert.ToInt32(reader["CategoryId"]);
                        et.CategoryName = Convert.ToString(reader["CategoryName"]);
                        et.TaskId       = Convert.ToInt32(reader["TaskId"]);
                        et.TaskName     = (string)reader["TaskName"];
                        et.BudgetHours  = Convert.ToString(reader["BudgetHours"]);
                        et.ActualHours  = Convert.ToString(reader["ActualHours"]);
                        et.StartDate    = Convert.ToString(reader["StartDate"]);
                        et.EndDate      = Convert.ToString(reader["EndDate"]);

                        if (!et.BudgetHours.Contains("."))
                        {
                            et.BudgetHours += ".0";
                        }
                        if (!et.ActualHours.Contains("."))
                        {
                            et.ActualHours += ".0";
                        }

                        tasks.Add(et);
                    }
                    reader.Close();
                }
                return(tasks);
            }
            catch (Exception ex)
            {
                string errTitle = this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;
                LogHardErrorMessage(errTitle, ex.Source, ex.Message);
                throw;
            }
        }
        public List <Task> GetActiveTasksBudgetSummary()
        {
            List <Task> tcrList = new List <Task>();

            try
            {
                using (SqlCommand cmd = new SqlCommand("Gsp_ActiveTasksBudgetSummary", _dbConn))
                {
                    cmd.CommandType = CommandType.StoredProcedure;

                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        Entity.Task et = new Entity.Task();
                        et.TaskName    = (string)reader["TaskName"];
                        et.BudgetHours = Convert.ToString(reader["BudgetHours"]);
                        et.StartDate   = Convert.ToString(reader["StartDate"]);
                        et.ActualHours = Convert.ToString(reader["TotalToDate"]);

                        if (!et.BudgetHours.Contains("."))
                        {
                            et.BudgetHours += ".0";
                        }
                        if (!et.ActualHours.Contains("."))
                        {
                            et.ActualHours += ".0";
                        }

                        tcrList.Add(et);
                    }
                    reader.Close();
                }
                return(tcrList);
            }
            catch (Exception ex)
            {
                string errTitle = this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;
                LogHardErrorMessage(errTitle, ex.Source, ex.Message);
                throw;
            }
        }