Пример #1
0
        /// <summary>
        /// Get all Tasks
        /// </summary>
        /// <returns>A TasksTD</returns>
        public static DataSet GetTasks()
        {
            TasksTD           td = new TasksTD();
            TasksTableAdapter ta = new TasksTableAdapter();

            ta.Fill(td.Tasks);
            ta.Dispose();
            return(td);
        }
Пример #2
0
 /// <summary>
 /// Validates the current IssuesRow.
 ///   This Row only validates the columns it uses from each different TableRow
 /// </summary>
 /// <returns>The row is valid</returns>
 public bool IsValidRow()
 {
     try
     {
         RowError  = String.Empty;
         RowError += TasksTD.CheckPrioritySequence(PrioritySequence.ToString());
     }
     catch (Exception ex)
     {
         RowError += ex.Message;
     }
     return(!HasErrors);
 }
Пример #3
0
        /// <summary>
        /// Service callable code to Delete/Insert/Update Issues
        /// </summary>
        /// <param name="cd">A ClientDataSet of type IssuesCD</param>
        /// <returns>A IssuesCD ClientDataSet. If ALL OK contains updated data, if not contains the RowErrors</returns>
        public static IssuesCD UpdateIssues(IssuesCD cd)
        {
            if (cd == null || cd.Tables["Issues"] == null || cd.Tables["Issues"].Rows.Count == 0)
            {
                throw new Exception("The DataSet and/or DataTable is null or empty.");
            }

            TasksTD.TasksDataTable   tt = new TasksTD.TasksDataTable();
            IssuesCD.IssuesDataTable ct = new IssuesCD.IssuesDataTable();

            foreach (IssuesRow modifiedRow in cd.Issues.Select("", "", DataViewRowState.ModifiedCurrent))
            {
                ct.Clear();                                      // clear for next row to import
                ct.ImportRow(modifiedRow);                       // import single row into Table for merge

                tt.Merge(TasksTD.GetTask(modifiedRow.TaskId));   // populate with all current columns
                tt.Merge(ct, false, MissingSchemaAction.Ignore); // overlay with updated columns
            }

            TasksTD td = new TasksTD();

            td.Tasks.BeginLoadData();
            td.Tasks.Merge(cd.Issues, false, MissingSchemaAction.Ignore);
            td.Tasks.Merge(tt, false, MissingSchemaAction.Ignore);

            SqlTransaction transaction = null;

            try
            {
                TasksTD.UpdateTasks(td, ref transaction);
                SqlUtils.CommitTransaction(transaction);

                if (transaction.Connection != null && transaction.Connection.State == ConnectionState.Open)
                {
                    transaction.Connection.Close();
                }
                transaction.Dispose();
            }
            catch (Exception ex)
            {
                SqlUtils.RollbackTransaction(transaction);
                throw ex;
            }

            return(cd);
        }