Beispiel #1
0
        // -----------------------------------------------------
        // Add Task Button -- Click Event Handler
        private void buttonAddTask_Click(object sender, EventArgs e)
        {
            // Putup a modal dialog where the user can pick a task
            // Don't show tasks that are already on the time card

            SsOpsDatabaseLibrary.Entity.Task[] theSelectedTasks;

            // Filtered tasks are the ones that are not already on the timecard
            if (_tcDetailsUnderGlass.Count != 0)
            {
                foreach (TimecardDetail tcd in _tcDetailsUnderGlass)
                {
                    foreach (Task task in _activeTasks)
                    {
                        if (task.TaskName == tcd.Task_Name)
                        {
                            _filteredTasks.Remove(task);
                        }
                    }
                }
            }

            using (SelectTaskForm stf = new SelectTaskForm(_filteredTasks))
            {
                Point targetPoint = this.Location;
                targetPoint.X = this.Location.X + 170;
                targetPoint.Y = this.Location.Y + 25;

                stf.Width    = 272;
                stf.Height   = 458;
                stf.Location = targetPoint;

                stf.ShowDialog(this);
                theSelectedTasks = stf.GetSelectedTasks();
                stf.Dispose();
            }

            if (theSelectedTasks != null)
            {
                //Add the selected task to the timecard
                TimecardDetail tcDetail;
                foreach (SsOpsDatabaseLibrary.Entity.Task tsk in theSelectedTasks)
                {
                    tcDetail           = new TimecardDetail();
                    tcDetail.Task_Name = tsk.TaskName;
                    tcDetail.TaskId    = Convert.ToInt32(tsk.TaskId);
                    _bindingSource1.Add(tcDetail);
                }
                //tcDetail.Task_Name= theSelectedTask.TaskName;
                //tcDetail.TaskId = Convert.ToInt32(theSelectedTask.TaskId);

                //adding a row to the binding source will in-turn add the row to our _timecardDetailsUnderGlass list
                //_bindingSource1.Add(tcDetail);
                //There are now changes made to this timecard that have not yet been committed to the DB
                _currentFormState = FormState.ViewingPotentialChanges;
                AssertFormState();
            }
        }
        public List <TimecardDetail> GetTimecardDetailsByTimecardId(int tcId)
        {
            SqlParameter          parm;
            List <TimecardDetail> listTcd = new List <TimecardDetail>();

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

                    parm = new SqlParameter("@timecardId", SqlDbType.Int);
                    cmd.Parameters.Add(parm);
                    parm.Value = tcId;
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        TimecardDetail tcd = new TimecardDetail();
                        tcd.DetailId   = Convert.ToInt32(reader["TcDetailId"]);
                        tcd.TaskId     = Convert.ToInt32(reader["TaskId"]);
                        tcd.TimecardId = Convert.ToInt32(reader["TimecardId"]);

                        tcd.PutValueForDay(Timecard.DetailFields.Monday_Hrs, Convert.ToDecimal(reader["MondayHrs"]));
                        tcd.PutValueForDay(Timecard.DetailFields.Tuesday_Hrs, Convert.ToDecimal(reader["TuesdayHrs"]));
                        tcd.PutValueForDay(Timecard.DetailFields.Wednesday_Hrs, Convert.ToDecimal(reader["WednesdayHrs"]));
                        tcd.PutValueForDay(Timecard.DetailFields.Thursday_Hrs, Convert.ToDecimal(reader["ThursdayHrs"]));
                        tcd.PutValueForDay(Timecard.DetailFields.Friday_Hrs, Convert.ToDecimal(reader["FridayHrs"]));
                        tcd.PutValueForDay(Timecard.DetailFields.Saturday_Hrs, Convert.ToDecimal(reader["SaturdayHrs"]));
                        tcd.PutValueForDay(Timecard.DetailFields.Sunday_Hrs, Convert.ToDecimal(reader["SundayHrs"]));

                        tcd.Task_Name = (string)reader["TaskName"];

                        listTcd.Add(tcd);
                    }
                    reader.Close();
                }
                return(listTcd);
            }
            catch (Exception ex)
            {
                string errTitle = this.GetType().Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name;
                LogHardErrorMessage(errTitle, ex.Source, ex.Message);
                throw;
            }
        }
        public List <TimecardDetail> GetTimecardDetailsByTimecardId(string tcId)
        {
            SqlParameter          parm;
            List <TimecardDetail> listTcd = new List <TimecardDetail>();

            try
            {
                using (SqlCommand cmd = new SqlCommand("Gsp_GetTimecardDetailByTimecardId", _dbConn))
                {
                    parm = new SqlParameter("@timecardId", SqlDbType.Int);
                    cmd.Parameters.Add(parm);
                    parm.Value = tcId;
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        TimecardDetail tcd = new TimecardDetail();
                        tcd.Detail_ID     = (string)reader["TcDetailId"];
                        tcd.Task_ID       = (string)reader["TaskId"];
                        tcd.Timecard_ID   = (string)reader["TimecardId"];
                        tcd.Monday_Hrs    = (string)reader["MondayHrs"];
                        tcd.Tuesday_Hrs   = (string)reader["TuesdayHrs"];
                        tcd.Wednesday_Hrs = (string)reader["WednesdayHrs"];
                        tcd.Thursday_Hrs  = (string)reader["ThursdayHrs"];
                        tcd.Friday_Hrs    = (string)reader["FridayHrs"];
                        tcd.Saturday_Hrs  = (string)reader["SaturdayHrs"];
                        tcd.Sunday_Hrs    = (string)reader["SundayHrs"];

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