Esempio n. 1
0
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of task information from the Tasks
        /// table, and then databind the results to a templated DataList
        /// server control.  It uses the Rainbow.TasksDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                sortField     = Settings["TASKS_SORT_FIELD"].ToString();
                sortDirection = "ASC";
//				if (sortField == "DueDate")
//					sortDirection = "DESC";
                ViewState["SortField"]     = sortField;
                ViewState["SortDirection"] = sortDirection;
            }
            else
            {
                sortField     = (string)ViewState["SortField"];
                sortDirection = (string)ViewState["sortDirection"];
            }

            myDataView = new DataView();

            // Obtain task information from Tasks table
            // and bind to the DataGrid Control
            TasksDB tasks = new TasksDB();

            DataSet taskData = tasks.GetTasks(ModuleID);

            myDataView = taskData.Tables[0].DefaultView;

            if (!Page.IsPostBack)
            {
                myDataView.Sort = sortField + " " + sortDirection;
            }

            BindGrid();
        }
Esempio n. 2
0
        /// <summary>
        /// The Page_Load event on this Page is used to obtain the ModuleID
        /// and ItemID of the task to display.
        /// It then uses the Rainbow.TasksDB() data component
        /// to populate the page's edit controls with the task details.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            // Verify that the current user has access to edit this module
            if (Rainbow.Security.PortalSecurity.HasEditPermissions(ModuleID))
            {
                EditLink  = "<a href= \"TasksEdit.aspx?ItemID=" + ItemID;
                EditLink += "&mID=" + ModuleID + "\" class=\"Normal\">Edit</a>";
            }

            if (Page.IsPostBack == false)
            {
                //Chris Farrell, [email protected], 5/28/04.
                //Improper Identity seed in the ItemID means that there may be tasks
                //with a ItemID = 0.  This is not the way it should be, but there is no
                //reason to NOT show the task with ItemID = 0 and that helps reduce
                //the pains from this bug for users who already have data present.

                // Obtain a single row of Task information
                TasksDB       Tasks = new TasksDB();
                SqlDataReader dr    = Tasks.GetSingleTask(ItemID);

                try
                {
                    // Read first row from database
                    if (dr.Read())
                    {
                        TitleField.Text           = (string)dr["Title"];
                        longdesc.Text             = (string)dr["Description"];
                        StartField.Text           = ((DateTime)dr["StartDate"]).ToShortDateString();
                        DueField.Text             = ((DateTime)dr["DueDate"]).ToShortDateString();
                        CreatedBy.Text            = (string)dr["CreatedByUser"];
                        ModifiedBy.Text           = (string)dr["ModifiedByUser"];
                        PercentCompleteField.Text = ((Int32)dr["PercentComplete"]).ToString();
                        AssignedField.Text        = (string)dr["AssignedTo"];
                        CreatedDate.Text          = ((DateTime)dr["CreatedDate"]).ToString();
                        ModifiedDate.Text         = ((DateTime)dr["ModifiedDate"]).ToString();
                        StatusField.Text          = Esperantus.Localize.GetString("TASK_STATE_" + (string)dr["Status"], (string)dr["Status"], StatusField);
                        PriorityField.Text        = Esperantus.Localize.GetString("TASK_PRIORITY_" + (string)dr["Priority"], (string)dr["Priority"], PriorityField);
                        // 15/7/2004 added localization by Mario Endara [email protected]
                        if (CreatedBy.Text == "unknown")
                        {
                            CreatedBy.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                        }
                        // 15/7/2004 added localization by Mario Endara [email protected]
                        if (ModifiedBy.Text == "unknown")
                        {
                            ModifiedBy.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                        }
                    }
                }
                finally
                {
                    dr.Close();
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// The OnUpdate event handler on this Page is used to either
        /// create or update an task. It uses the Rainbow.TasksDB()
        /// data component to encapsulate all data functionality.
        /// Note: This procedure is automaticall called on Update
        /// </summary>
        /// <param name="e"></param>
        protected override void OnUpdate(EventArgs e)
        {
            // Calling base we check if the user has rights on updating
            base.OnUpdate(e);

            // Only Update if the Entered Data is Valid
            if (Page.IsValid == true)
            {
                // Create an instance of the Task DB component
                TasksDB tasks = new TasksDB();

                if (ItemID == 0)
                {
                    // Add the task within the Tasks table

                    //by Manu
                    //First get linked task modules
                    string[] linkedModules = moduleSettings["TASKS_LINKED_MODULES"].ToString().Split(';');

                    for (int i = 0; i < linkedModules.Length; i++)
                    {
                        int linkedModuleID = int.Parse(linkedModules[i]);

                        //If not module is null or current
                        if (linkedModuleID != 0 && linkedModuleID != ModuleID)
                        {
                            //Add to linked

                            //Get default assignee from module setting
                            Hashtable linkedModuleSettings = ModuleSettings.GetModuleSettings(linkedModuleID, this);
                            string    linkedModuleAssignee = linkedModuleSettings["TASKS_DEFAULT_ASSIGNEE"].ToString();

                            tasks.AddTask(linkedModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, TitleField.Text, DateTime.Parse(StartField.Text), DesktopText.Text, StatusField.SelectedItem.Value, PriorityField.SelectedItem.Value, linkedModuleAssignee, DateTime.Parse(DueField.Text), Int16.Parse(PercentCompleteField.Text));
                        }
                    }

                    //Add to current
                    tasks.AddTask(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, TitleField.Text, DateTime.Parse(StartField.Text), DesktopText.Text, StatusField.SelectedItem.Value, PriorityField.SelectedItem.Value, AssignedField.Text, DateTime.Parse(DueField.Text), Int16.Parse(PercentCompleteField.Text));
                }
                else
                {
                    // Update the task within the Tasks table
                    tasks.UpdateTask(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, TitleField.Text, DateTime.Parse(StartField.Text), DesktopText.Text, StatusField.SelectedItem.Value, PriorityField.SelectedItem.Value, AssignedField.Text, DateTime.Parse(DueField.Text), Int16.Parse(PercentCompleteField.Text));
                }

                // Redirect back to the portal home page
                this.RedirectBackToReferringPage();
            }
        }
Esempio n. 4
0
        /// <summary>
        /// The OnDelete event handler on this Page is used to delete
        /// an task. It uses the Rainbow.TasksDB() data component to
        /// encapsulate all data functionality.
        /// Note:This procedure is automaticall called on Update
        /// </summary>
        /// <param name="e"></param>
        override protected void OnDelete(EventArgs e)
        {
            // Calling base we check if the user has rights on deleting
            base.OnUpdate(e);

            // Only attempt to delete the item if it is an existing item
            // (new items will have "ItemID" of 0)

            if (ItemID != 0)
            {
                TasksDB tasks = new TasksDB();
                tasks.DeleteTask(ItemID);
            }

            // Redirect back to the portal home page
            this.RedirectBackToReferringPage();
        }
Esempio n. 5
0
        /// <summary>
        /// The Page_Load event on this Page is used to obtain the ModuleID
        /// and ItemID of the task to edit.
        /// It then uses the Rainbow.TasksDB() data component
        /// to populate the page's edit controls with the task details.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Page_Load(object sender, System.EventArgs e)
        {
            // If the page is being requested the first time, determine if an
            // task itemID value is specified, and if so populate page
            // contents with the task details

            //Chris Farrell, [email protected], 5/28/04
            //Added support for Rainbow WYSIWYG editors.
            //Editor placeholder setup
            Rainbow.UI.DataTypes.HtmlEditorDataType h = new Rainbow.UI.DataTypes.HtmlEditorDataType();
            h.Value     = moduleSettings["Editor"].ToString();
            DesktopText = h.GetEditor(DescriptionField, ModuleID, bool.Parse(moduleSettings["ShowUpload"].ToString()), portalSettings);

            DesktopText.Width  = new System.Web.UI.WebControls.Unit(moduleSettings["Width"].ToString());
            DesktopText.Height = new System.Web.UI.WebControls.Unit(moduleSettings["Height"].ToString());
            //end Chris Farrell changes, 5/28/04


            //Set right popup url
            StartField.xPopupURL = Rainbow.Settings.Path.ApplicationRoot + "/DesktopModules/DateTextBox/popupcalendar.aspx";
            StartField.xImageURL = Rainbow.Settings.Path.ApplicationRoot + "/DesktopModules/DateTextBox/calendar.jpg";
            DueField.xPopupURL   = Rainbow.Settings.Path.ApplicationRoot + "/DesktopModules/DateTextBox/popupcalendar.aspx";
            DueField.xImageURL   = Rainbow.Settings.Path.ApplicationRoot + "/DesktopModules/DateTextBox/calendar.jpg";

            if (Page.IsPostBack == false)
            {
                StartField.Text = DateTime.Now.ToShortDateString();
                DueField.Text   = DateTime.Now.ToShortDateString();
                AddListItem("TASK_STATE_0", "Not Started", StatusField);
                AddListItem("TASK_STATE_1", "In Progress", StatusField);
                AddListItem("TASK_STATE_2", "Complete", StatusField);
                StatusField.SelectedIndex = 0;
                AddListItem("TASK_PRIORITY_0", "High", PriorityField);
                AddListItem("TASK_PRIORITY_1", "Normal", PriorityField);
                AddListItem("TASK_PRIORITY_2", "Low", PriorityField);

                PriorityField.SelectedIndex = 1;
                if (ItemID != 0)
                {
                    // Obtain a single row of Task information
                    TasksDB       Tasks = new TasksDB();
                    SqlDataReader dr    = Tasks.GetSingleTask(ItemID);

                    try
                    {
                        // Read first row from database
                        if (dr.Read())
                        {
                            TitleField.Text             = (string)dr["Title"];
                            StartField.Text             = ((DateTime)dr["StartDate"]).ToShortDateString();
                            DueField.Text               = ((DateTime)dr["DueDate"]).ToShortDateString();
                            CreatedBy.Text              = (string)dr["CreatedByUser"];
                            ModifiedBy.Text             = (string)dr["ModifiedByUser"];
                            PercentCompleteField.Text   = ((Int32)dr["PercentComplete"]).ToString();
                            AssignedField.Text          = (string)dr["AssignedTo"];
                            CreatedDate.Text            = ((DateTime)dr["CreatedDate"]).ToString();
                            ModifiedDate.Text           = ((DateTime)dr["ModifiedDate"]).ToString();
                            StatusField.SelectedIndex   = Convert.ToInt16((string)dr["Status"]);
                            PriorityField.SelectedIndex = Convert.ToInt16((string)dr["Priority"]);
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (CreatedBy.Text == "unknown")
                            {
                                CreatedBy.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (ModifiedBy.Text == "unknown")
                            {
                                ModifiedBy.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }

                            //Chris Farrell, [email protected], 5/28/04
                            //DescriptionField.Text = (string) dr["Description"];
                            DesktopText.Text = (string)dr["Description"];
                        }
                    }
                    finally
                    {
                        dr.Close();
                    }
                }
                else                 //default for new
                {
                    AssignedField.Text = moduleSettings["TASKS_DEFAULT_ASSIGNEE"].ToString();
                }
            }
        }