示例#1
0
        /*************************************************************************
        *   Repeater Items
        *   DataBound functionality for the Edit Inspection Section.
        *   Invoked everytime the page reloads and the dataset is loaded into the table.
        *     Gets repair information, traverses through the dynamically populated form,
        *     to set the values.
        *     Marks the failures, severity, and comments.
        **************************************************************************/
        protected void Repeater_items_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem element = e.Item;

            List<RepairItem> Repairs = new List<RepairItem>();

            Label lbl_element_id = (Label)element.FindControl("lbl_elementsId");

            if (lbl_element_id != null)
            {
                int id = int.Parse(lbl_element_id.Text);

                foreach (RepeaterItem item in Repeater_repairs.Items)
                {
                    RepairItem repair = new RepairItem();

                    TextBox tb1 = (TextBox)item.FindControl("txt_inspection_id");
                    repair.inspection_id = int.Parse(tb1.Text);

                    TextBox tb2 = (TextBox)item.FindControl("txt_element_id");
                    repair.element_id = int.Parse(tb2.Text);

                    TextBox tb3 = (TextBox)item.FindControl("txt_notes");
                    repair.notes = tb3.Text;
                    string[] noteArr = repair.notes.Split('/');
                    foreach (string s in noteArr)
                    {
                        repair.items.Add(s.Trim());
                    }

                    Label lbl_s = (Label)item.FindControl("lbl_severity_id");
                    repair.severity_id = int.Parse(lbl_s.Text);

                    Repairs.Add(repair);
                }

                foreach (RepairItem r in Repairs)
                {
                    if (r.element_id == id)
                    {
                        //mark the failure
                        CheckBox cb = (CheckBox)element.FindControl("cb_fail");
                        cb.Checked = true;

                        //mark the severity
                        DropDownList ddl_s = (DropDownList)element.FindControl("ddl_severity");
                        ddl_s.SelectedIndex = r.severity_id;

                        Repeater rep = (Repeater)element.FindControl("Repeater_elements");
                        foreach (RepeaterItem ri in rep.Items)
                        {
                            CheckBox cb_e = (CheckBox)ri.FindControl("cb_elements");
                            if (cb_e != null)
                            {
                                if (r.items.Contains(cb_e.Text))
                                {
                                    cb_e.Checked = true;
                                    r.items.Remove(cb_e.Text);
                                }
                            }
                        }

                        //mark the severity
                        TextBox txt_comments = (TextBox)element.FindControl("txt_comments");
                        txt_comments.Text = r.items.Last();
                    }
                }
            }
        }
示例#2
0
        /*************************************************************************
        *   Repeater Elements
        *   DataBound functionality for the Edit Inspection Section.
        *   Invoked everytime the page reloads and the dataset is loaded into the table.
        *     Gets repair information, traverses through the dynamically populated form,
        *     to set the values.
        *     Marks the checkboxes.
        *   TODO: Flaw - Currently, last checkbox does not show up as checked
        *                after modification and page reload if
        *         no comments were initially provided in the original inspection.
        **************************************************************************/
        protected void Repeater_elements_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            RepeaterItem element = e.Item;

            CheckBox cb_e = (CheckBox)element.FindControl("cb_elements");
            if (cb_e != null)
            {
                RepeaterItem row = (RepeaterItem)cb_e.Parent.Parent.Parent;
                Label lbl_element_id = (Label)row.FindControl("lbl_elementsId");
                int element_id = int.Parse(lbl_element_id.Text);

                foreach (RepeaterItem item in Repeater_repairs.Items)
                {
                    RepairItem repair = new RepairItem();

                    TextBox tb1 = (TextBox)item.FindControl("txt_inspection_id");
                    repair.inspection_id = int.Parse(tb1.Text);

                    TextBox tb2 = (TextBox)item.FindControl("txt_element_id");
                    repair.element_id = int.Parse(tb2.Text);

                    if (repair.element_id == element_id)
                    {
                        TextBox tb3 = (TextBox)item.FindControl("txt_notes");
                        repair.notes = tb3.Text;
                        string[] noteArr = repair.notes.Split('/');
                        foreach (string s in noteArr)
                        {
                            repair.items.Add(s.Trim());
                        }

                        if (repair.items.Contains(cb_e.Text))
                            cb_e.Checked = true;
                    }
                }
            }
        }