Пример #1
0
        public static bool DeleteGoal(Goal goal)
        {
            bool returnValue = false;

            List<IBaseQueryData> queryDatum = new List<IBaseQueryData>();

            IBaseQueryData queryData = new DeleteQueryData();
            queryData.TableName = "PLN_GoalCategories";
            queryData.KeyFields.Add(new FieldData { FieldName = "GoalID", FieldType = SqlDbType.Int, FieldValue = goal.GoalID.ToString() });
            queryDatum.Add(queryData);

            queryData = new DeleteQueryData();
            queryData.TableName = "PLN_GoalSteps";
            queryData.KeyFields.Add(new FieldData { FieldName = "GoalID", FieldType = SqlDbType.Int, FieldValue = goal.GoalID.ToString() });
            queryDatum.Add(queryData);

            queryData = new DeleteQueryData();
            queryData.TableName = "PLN_Goals";
            queryData.KeyFields.Add(new FieldData { FieldName = "GoalID", FieldType = SqlDbType.Int, FieldValue = goal.GoalID.ToString() });
            queryDatum.Add(queryData);

            returnValue = SQLWrapper.ExecuteQuery(queryDatum);

            if (goal.Steps != null)
            {
                for (int i = 0; i <= goal.Steps.Count - 1; i++)
                {
                    DALTask.DeleteTask(goal.Steps[i].taskInfo);
                }
            }

            return returnValue;
        }
Пример #2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     bool returnValue = false;
     if (isValidData(true))
     {
         if (IsPageDirty)
         {
             Goal goal = null;
             switch (this.CurrentPageMode)
             {
                 case PageMode.Add:
                     {
                         goal = new Goal();
                         break;
                     }
                 case PageMode.Edit:
                     {
                         goal = BLLGoal.GetGoalByID(Convert.ToInt32(this.lblItemID.Text));
                         break;
                     }
             }
             goal.GoalSubject = this.txtSubject.Text;
             goal.GoalReason = this.txtReason.Text;
             goal.GoalNotes = this.txtNotes.Text;
             goal.ForUser = this.CurrentUser;
             goal.DueOn = DateTime.Today.AddYears(1);
             goal.Categories.Clear();
             foreach (object itemChecked in chklstCategory.CheckedItems)
             {
                 Category category = itemChecked as Category;
                 goal.Categories.Add(BLLCategory.GetCategoryByID(category.CategoryID));
             }
             switch (this.CurrentPageMode)
             {
                 case PageMode.Add:
                     {
                         returnValue = BLLGoal.AddGoal(goal);
                         break;
                     }
                 case PageMode.Edit:
                     {
                         returnValue = BLLGoal.UpdateGoal(goal);
                         break;
                     }
             }
             goal = null;
         }
         this.Hide();
         this.Close();
     }
 }
Пример #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            if (isValidData())
            {
                Goal goal = new Goal();
                if (CurrentPageMode != PageMode.Add)
                {
                    goal = BLLGoal.GetGoalByID(Convert.ToInt32(this.txtGoalID.Text));
                }
                try
                {
                    goal.ForUser = new AppUser();
                    goal.ForUser.UserID = 1;
                    goal.GoalNotes = this.txtGoalNotes.Text;
                    goal.GoalReason = this.txtReason.Text;
                    goal.GoalSubject = this.txtSubject.Text;
                    goal.Categories = new List<Category>();
                    for (int i = 0; i <= chklstCategory.Items.Count - 1; i++)
                    {
                        if (chklstCategory.Items[i].Selected)
                        {
                            goal.Categories.Add(BLLCategory.GetCategoryByID(Convert.ToInt32(chklstCategory.Items[i].Value)));
                        }
                    }
                    if (CurrentPageMode == PageMode.Add)
                    {
                        BLLGoal.AddGoal(goal);
                        this.lblErrorText.Text = "Completed";
                    }
                    else if (CurrentPageMode == PageMode.Edit)
                    {
                        BLLGoal.UpdateGoal(goal);
                        this.lblErrorText.Text = "Completed";
                    }
                    else
                    {
                        throw new Exception("Invalid Action");
                    }
                    string script = "<script language='javascript' type='text/javascript'>window.returnValue = 1;;window.close();</script>";
                    Page.RegisterClientScriptBlock("closescript", script);
                }
                catch (Exception ex)
                {
                    this.lblErrorText.Text = ex.Message;
                    this.txtSubject.Focus();
                }

            }
        }
Пример #4
0
        public static bool AddGoal(Goal goal)
        {
            bool returnValue = false;

            int goalID = getNextGoalID();

            List<IBaseQueryData> queryDatum = new List<IBaseQueryData>();

            IBaseQueryData queryData = new InsertQueryData();
            queryData.TableName = "PLN_Goals";
            queryData.Fields.Add(new FieldData { FieldName = "GoalID", FieldType = SqlDbType.Int, FieldValue = goalID.ToString() });
            queryData.Fields.Add(new FieldData { FieldName = "UserId", FieldType = SqlDbType.Int, FieldValue = goal.ForUser.UserID.ToString() });
            queryData.Fields.Add(new FieldData { FieldName = "IsCompleted", FieldType = SqlDbType.Bit, FieldValue = goal.IsCompleted ? "1" : "0" });
            queryData.Fields.Add(new FieldData { FieldName = "GoalSubject", FieldType = SqlDbType.NVarChar, FieldValue = goal.GoalSubject.Trim() });
            queryData.Fields.Add(new FieldData { FieldName = "GoalReason", FieldType = SqlDbType.NVarChar, FieldValue = goal.GoalReason.Trim() });
            queryData.Fields.Add(new FieldData { FieldName = "GoalNotes", FieldType = SqlDbType.NVarChar, FieldValue = goal.GoalNotes.Trim() });
            queryData.Fields.Add(new FieldData { FieldName = "DueOn", FieldType = SqlDbType.Date, FieldValue = goal.DueOn.ToString(Constants.DATE_FORMAT_SQL) });
            if (goal.Sequence <= 0)
            {
                goal.Sequence = GetGoalsForUser(goal.ForUser.UserID, null).Count + 1;
            }
            queryData.Fields.Add(new FieldData { FieldName = "Sequence", FieldType = SqlDbType.Int, FieldValue = goal.Sequence.ToString() });

            queryDatum.Add(queryData);

            for (int i = 0; i <= goal.Categories.Count - 1; i++)
            {
                queryData = new InsertQueryData();

                queryData.TableName = "PLN_GoalCategories";
                queryData.Fields.Add(new FieldData { FieldName = "GoalID", FieldType = SqlDbType.Int, FieldValue = goalID.ToString() });
                queryData.Fields.Add(new FieldData { FieldName = "CategoryID", FieldType = SqlDbType.Int, FieldValue = goal.Categories[i].CategoryID.ToString() });
                queryData.Fields.Add(new FieldData { FieldName = "Sequence", FieldType = SqlDbType.Int, FieldValue = (i + 1).ToString() });
                queryDatum.Add(queryData);
            }

            returnValue = SQLWrapper.ExecuteQuery(queryDatum);

            return returnValue;
        }
Пример #5
0
        private static Goal loadGoal(DataTable dtGoals, int RowNo)
        {
            Goal goal = new Goal();
            goal.GoalID = Convert.ToInt32(dtGoals.Rows[RowNo]["GoalID"]);
            goal.GoalSubject = dtGoals.Rows[RowNo]["GoalSubject"].ToString();
            goal.GoalReason = dtGoals.Rows[RowNo]["GoalReason"].ToString();
            goal.GoalNotes = dtGoals.Rows[RowNo]["GoalNotes"].ToString();
            goal.IsCompleted = Convert.ToBoolean(dtGoals.Rows[RowNo]["IsCompleted"]);
            goal.Sequence = Convert.ToInt32(dtGoals.Rows[RowNo]["Sequence"]);
            goal.ForUser = DALAppUser.GetUserByID(Convert.ToInt32(dtGoals.Rows[RowNo]["UserID"]));
            goal.DueOn = Convert.ToDateTime(dtGoals.Rows[RowNo]["DueOn"]);

            goal.Categories = loadGoalCategories(goal.GoalID);

            goal.Steps = DALGoalStep.GetGoalStepsByGoalID(goal.GoalID);

            //for (int k = 0; k <= goal.Steps.Count - 1; k++)
            //{
            //    if (goal.Steps[k].taskInfo != null)
            //    {
            //        if (goal.DueOn == null)
            //        {
            //            goal.DueOn = goal.Steps[k].taskInfo.TaskDate;
            //        }
            //        else
            //        {
            //            if (goal.Steps[k].taskInfo.TaskDate > goal.DueOn)
            //            {
            //                goal.DueOn = goal.Steps[k].taskInfo.TaskDate;
            //            }
            //        }
            //    }
            //}

            return goal;
        }
Пример #6
0
 public static bool UpdateGoal(Goal goal)
 {
     return DALGoal.UpdateGoal(goal);
 }
Пример #7
0
 public static bool AddGoal(Goal goal)
 {
     return DALGoal.AddGoal(goal);
 }