Ejemplo n.º 1
0
        /// <summary>
        /// The UpdateBtn_Click event handler on this Page is used to either
        /// create or update a contact.  It  uses the Rainbow.ContactsDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        protected override void OnUpdate(EventArgs e)
        {
            base.OnUpdate(e);

            // Only Update if Entered data is Valid
            if (Page.IsValid == true)
            {
                // Create an instance of the ContactsDB component
                ContactsDB contacts = new ContactsDB();

                if (ItemID == 0)
                {
                    // Add the contact within the contacts table
                    contacts.AddContact(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, NameField.Text, RoleField.Text, EmailField.Text, Contact1Field.Text, Contact2Field.Text, FaxField.Text, AddressField.Text);
                }
                else
                {
                    // Update the contact within the contacts table
                    contacts.UpdateContact(ModuleID, ItemID, PortalSettings.CurrentUser.Identity.Email, NameField.Text, RoleField.Text, EmailField.Text, Contact1Field.Text, Contact2Field.Text, FaxField.Text, AddressField.Text);
                }

                // Redirect back to the portal home page
                this.RedirectBackToReferringPage();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The DeleteBtn_Click event handler on this Page is used to delete an
        /// a contact.  It  uses the Rainbow.ContactsDB()
        /// data component to encapsulate all data functionality.
        /// </summary>
        protected override void OnDelete(EventArgs e)
        {
            base.OnDelete(e);

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

            if (ItemID != 0)
            {
                ContactsDB contacts = new ContactsDB();
                contacts.DeleteContact(ItemID);
            }

            // Redirect back to the portal home page
            this.RedirectBackToReferringPage();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// The Page_Load event on this Page is used to obtain the ModuleID
        /// and ItemID of the contact to edit.
        ///
        /// It then uses the Rainbow.ContactsDB() data component
        /// to populate the page's edit controls with the contact 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
            // contact itemID value is specified, and if so populate page
            // contents with the contact details
            if (Page.IsPostBack == false)
            {
                if (ItemID != 0)
                {
                    // Obtain a single row of contact information
                    ContactsDB    contacts = new ContactsDB();
                    SqlDataReader dr       = contacts.GetSingleContact(ItemID, WorkFlowVersion.Staging);

                    try
                    {
                        // Read first row from database
                        if (dr.Read())
                        {
                            NameField.Text     = (dr["Name"] == DBNull.Value) ? string.Empty : (string)(dr["Name"]);
                            RoleField.Text     = (dr["Role"] == DBNull.Value) ? string.Empty : (string)(dr["Role"]);
                            EmailField.Text    = (dr["Email"] == DBNull.Value) ? string.Empty : (string)(dr["Email"]);
                            Contact1Field.Text = (dr["Contact1"] == DBNull.Value) ? string.Empty : (string)(dr["Contact1"]);
                            Contact2Field.Text = (dr["Contact2"] == DBNull.Value) ? string.Empty : (string)(dr["Contact2"]);
                            FaxField.Text      = (dr["Fax"] == DBNull.Value) ? string.Empty : (string)(dr["Fax"]);
                            AddressField.Text  = (dr["Address"] == DBNull.Value) ? string.Empty : (string)(dr["Address"]);
                            CreatedBy.Text     = (dr["CreatedByUser"] == DBNull.Value) ? string.Empty : (string)(dr["CreatedByUser"]);
                            CreatedDate.Text   = (dr["CreatedDate"] == DBNull.Value) ? DateTime.Now.ToShortDateString() : ((DateTime)dr["CreatedDate"]).ToShortDateString();
                            // 15/7/2004 added localization by Mario Endara [email protected]
                            if (CreatedBy.Text == "unknown")
                            {
                                CreatedBy.Text = Esperantus.Localize.GetString("UNKNOWN", "unknown");
                            }
                        }
                    }
                    finally
                    {
                        // Close datareader
                        dr.Close();
                    }
                }
                else
                {
                    deleteButton.Visible = false; // Cannot delete an unexsistent item
                }
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// The Page_Load event handler on this User Control is used to
        /// obtain a DataReader of contact information from the Contacts
        /// table, and then databind the results to a DataGrid
        /// server control.  It uses the Rainbow.ContactsDB()
        /// 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)
        {
            //MH: Added  01/10/2003 [[email protected]]
            //set visibility of the columns
            myDataGrid.Columns[3].Visible = (Settings["SHOW_COLUMN_EMAIL"] != null)    ? bool.Parse(Settings["SHOW_COLUMN_EMAIL"].ToString()): true;
            myDataGrid.Columns[4].Visible = (Settings["SHOW_COLUMN_CONTACT1"] != null) ? bool.Parse(Settings["SHOW_COLUMN_CONTACT1"].ToString()): true;
            myDataGrid.Columns[5].Visible = (Settings["SHOW_COLUMN_CONTACT2"] != null) ? bool.Parse(Settings["SHOW_COLUMN_CONTACT2"].ToString()): true;
            myDataGrid.Columns[6].Visible = (Settings["SHOW_COLUMN_FAX"] != null)      ? bool.Parse(Settings["SHOW_COLUMN_FAX"].ToString()): true;
            myDataGrid.Columns[7].Visible = (Settings["SHOW_COLUMN_ADDRESS"] != null)  ? bool.Parse(Settings["SHOW_COLUMN_ADDRESS"].ToString()): true;
            //MH: End

            if (Page.IsPostBack == false)
            {
                sortField     = "Name";
                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 contact information from Contacts table
            // and bind to the DataGrid Control
            ContactsDB contacts = new ContactsDB();

            DataSet contactData = contacts.GetContacts(ModuleID, Version);

            myDataView = contactData.Tables[0].DefaultView;

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

            BindGrid();
        }