Ejemplo n.º 1
0
        /// <summary>
        /// Copies end date to start date if no start date
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void SetBlurEvent(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Get start and end date fields
                CaisisTextBox startDate = e.Row.FindControl("EventStartDate") as CaisisTextBox;
                CaisisTextBox endDate   = e.Row.FindControl("EventEndDate") as CaisisTextBox;

                // Manually set date's to friendly short date string
                string sDate = DataBinder.Eval(e.Row.DataItem, ProjectStageEvent.EventStartDate).ToString();
                string eDate = DataBinder.Eval(e.Row.DataItem, ProjectStageEvent.EventEndDate).ToString();
                if (!string.IsNullOrEmpty(sDate))
                {
                    startDate.Value = DateTime.Parse(sDate).ToShortDateString();
                }
                if (!string.IsNullOrEmpty(eDate))
                {
                    endDate.Value = DateTime.Parse(eDate).ToShortDateString();
                }
                // Add blur,focus, and click event to enddate control
                string script = "handleEndDateEntered('" + startDate.ClientID + "','" + endDate.ClientID + "');";
                PageUtil.AttachClientEventToControl(endDate as WebControl, "onclick", script);
                PageUtil.AttachClientEventToControl(endDate as WebControl, "onfocus", script);
                PageUtil.AttachClientEventToControl(endDate as WebControl, "onblur", script);
            }
        }
Ejemplo n.º 2
0
        protected void BindOrganizationsAndContacts(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                // Get the org drop down, contact drop down and contactid hidden field
                CaisisSelect organizationIdField = e.Row.FindControl("OrganizationEdit") as CaisisSelect;
                HtmlSelect   contactDropDown     = e.Row.FindControl("ContactNameEdit") as HtmlSelect;
                CaisisHidden contactIdField      = e.Row.FindControl("ContactId") as CaisisHidden;

                // Attach change events to the dropdowns to handle respective client events
                string onOrgChange = "onOrgChange(this,'" + organizationIdField.ClientID + "','" + contactDropDown.ClientID + "');";
                PageUtil.AttachClientEventToControl(organizationIdField as WebControl, "onchange", onOrgChange);
                string onContactSelChange = "copyToContactId(this,'" + contactIdField.ClientID + "');";
                contactDropDown.Attributes["onchange"] = onContactSelChange;

                // Populate Organizations and Contacts
                organizationIdField.DataSource = orgList;
                organizationIdField.DataBind();

                string orgId = DataBinder.Eval(e.Row.DataItem, "OrganizationId").ToString();
                // Set selected orgid
                organizationIdField.Value = orgId;

                // Populate Contacts
                if (!string.IsNullOrEmpty(orgId))
                {
                    ProjectManagementDa da       = new ProjectManagementDa();
                    DataTable           contacts = da.GetAllContactsByOrgId(int.Parse(orgId));
                    contactDropDown.DataSource = contacts;
                    contactDropDown.DataBind();
                    // Add blank item at beginning
                    contactDropDown.Items.Insert(0, new ListItem(string.Empty, string.Empty));

                    // Set value of associated contact
                    string contactId = DataBinder.Eval(e.Row.DataItem, "ContactId").ToString();
                    if (!string.IsNullOrEmpty(contactId))
                    {
                        contactDropDown.Value = contactId;
                        contactIdField.Value  = contactId;
                    }
                }
            }
        }