示例#1
0
        public void Load(DataTable dtTasks, RootObject sdCat, string id, ServiceCatalog p, string ServiceID)
        {
            txtMessage.Text = "";

            sdCategories = sdCat;
            taskID       = id;
            parent       = p;
            serviceID    = ServiceID;

            DataTable dtCategories = new DataTable();

            dtCategories.Columns.Add("Name");

            foreach (var cat in sdCategories.operation.Details)
            {
                dtCategories.Rows.Add(cat.NAME);
            }
            dgCat.ItemsSource = dtCategories.DefaultView;

            dgSubCat.ItemsSource = null;
            dgItem.ItemsSource   = null;
            dgSLA.ItemsSource    = parent.dtSLA.DefaultView;

            if (id != "")
            {
                lblTitle.Text = "Edit Task";
                foreach (DataRow dr in dtTasks.Rows)
                {
                    if (dr["TaskID"].ToString() == id)
                    {
                        txtName.Text    = dr["Name"].ToString();
                        rectBiz.Opacity = (dr["ForBusinessAssoc"].ToString() == "True") ? 1d : 0.2d;
                        rectOps.Opacity = (dr["ForOperationsAssoc"].ToString() == "True") ? 1d : 0.2d;
                        rectIT.Opacity  = (dr["ForITAssoc"].ToString() == "True") ? 1d : 0.2d;

                        string cat  = dr["ServiceDeskCategory"].ToString();
                        string sub  = dr["ServiceDeskSubCategory"].ToString();
                        string item = dr["ServiceDeskItem"].ToString();

                        txtDescription.Text = dr["Description"].ToString();

                        setDataGridByColumn(dgSLA, "ServiceLevelAgreementID", dr["ServiceLevelAgreementID"].ToString());

                        if (cat != "")
                        {
                            if (setDataGridToValue(dgCat, cat) == false)
                            {
                                txtMessage.Text = "Category \"" + cat + "\" is not in ServiceDesk";
                            }
                            else
                            {
                                fillSubcategories(cat);
                                if (sub != "")
                                {
                                    if (setDataGridToValue(dgSubCat, sub) == false)
                                    {
                                        txtMessage.Text = "Subcategory \"" + sub + "\" is not in ServiceDesk under category " + cat;
                                    }
                                    else
                                    {
                                        fillItmes(cat, sub);
                                        if (item != "")
                                        {
                                            if (setDataGridToValue(dgItem, item) == false)
                                            {
                                                txtMessage.Text = "Item \"" + item + "\" is not in ServiceDesk under category " + cat + " and subcategory " + sub;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            else
            {
                lblTitle.Text          = "Add Task";
                txtName.Text           = "";
                txtDescription.Text    = "";
                rectBiz.Opacity        = 1d;
                rectOps.Opacity        = 1d;
                rectIT.Opacity         = 1d;
                dgSLA.SelectedIndex    = -1;
                dgCat.SelectedIndex    = -1;
                dgSubCat.SelectedIndex = -1;
                dgItem.SelectedIndex   = -1;
            }


            //loadGroupData();
            //dgIcons.ItemsSource = dtGroups.DefaultView;

            //foreach (DataRow dr in dtGroups.Rows)
            //{
            //    if (dr["ID"].ToString() == id)
            //    {
            //        txtName.Text = dr["Name"].ToString();
            //        txtButtonText.Text = dr["ButtonText"].ToString();
            //        txtButtonTitle.Text = dr["ButtonTitle"].ToString();
            //    }
            //}
        }
        public void Load()
        {
            DataTable dtCategories = new DataTable();

            dtCategories.Columns.Add("Name");

            sdCategories = SDTicket.readCategorySubcategoryAndItem();

            foreach (var cat in sdCategories.operation.Details)
            {
                dtCategories.Rows.Add(cat.NAME);
            }
            dgCat.ItemsSource = dtCategories.DefaultView;



            /*
             * txtMessage.Text = "";
             *
             * sdCategories = sdCat;
             * taskID = id;
             * parent = p;
             * serviceID = ServiceID;
             *
             * DataTable dtCategories = new DataTable();
             * dtCategories.Columns.Add("Name");
             *
             * foreach (var cat in sdCategories.operation.Details)
             *  dtCategories.Rows.Add(cat.NAME);
             * dgCat.ItemsSource = dtCategories.DefaultView;
             *
             * dgSubCat.ItemsSource = null;
             * dgItem.ItemsSource = null;
             * dgSLA.ItemsSource = parent.dtSLA.DefaultView;
             *
             * if (id != "")
             * {
             *  lblTitle.Text = "Edit Task";
             *  foreach (DataRow dr in dtTasks.Rows)
             *  {
             *      if (dr["TaskID"].ToString() == id)
             *      {
             *          txtName.Text = dr["Name"].ToString();
             *          rectBiz.Opacity = (dr["ForBusinessAssoc"].ToString() == "True") ? 1d : 0.2d;
             *          rectOps.Opacity = (dr["ForOperationsAssoc"].ToString() == "True") ? 1d : 0.2d;
             *          rectIT.Opacity = (dr["ForITAssoc"].ToString() == "True") ? 1d : 0.2d;
             *
             *          string cat = dr["ServiceDeskCategory"].ToString();
             *          string sub = dr["ServiceDeskSubCategory"].ToString();
             *          string item = dr["ServiceDeskItem"].ToString();
             *
             *          txtDescription.Text = dr["Description"].ToString();
             *
             *          setDataGridByColumn(dgSLA, "ServiceLevelAgreementID", dr["ServiceLevelAgreementID"].ToString());
             *
             *          if (cat != "")
             *          {
             *              if (setDataGridToValue(dgCat, cat) == false)
             *              {
             *                  txtMessage.Text = "Category \"" + cat + "\" is not in ServiceDesk";
             *              }
             *              else
             *              {
             *                  fillSubcategories(cat);
             *                  if (sub != "")
             *                  {
             *                      if (setDataGridToValue(dgSubCat, sub) == false)
             *                      {
             *                          txtMessage.Text = "Subcategory \"" + sub + "\" is not in ServiceDesk under category " + cat;
             *                      }
             *                      else
             *                      {
             *                          fillItmes(cat, sub);
             *                          if (item != "")
             *                          {
             *                              if (setDataGridToValue(dgItem, item) == false)
             *                                  txtMessage.Text = "Item \"" + item + "\" is not in ServiceDesk under category " + cat + " and subcategory " + sub;
             *                          }
             *                      }
             *                  }
             *              }
             *          }
             *      }
             *  }
             * }
             *
             * else
             * {
             *  lblTitle.Text = "Add Task";
             *  txtName.Text = "";
             *  txtDescription.Text = "";
             *  rectBiz.Opacity = 1d;
             *  rectOps.Opacity = 1d;
             *  rectIT.Opacity = 1d;
             *  dgSLA.SelectedIndex = -1;
             *  dgCat.SelectedIndex = -1;
             *  dgSubCat.SelectedIndex = -1;
             *  dgItem.SelectedIndex = -1;
             * }
             *
             *
             * //loadGroupData();
             * //dgIcons.ItemsSource = dtGroups.DefaultView;
             *
             * //foreach (DataRow dr in dtGroups.Rows)
             * //{
             * //    if (dr["ID"].ToString() == id)
             * //    {
             * //        txtName.Text = dr["Name"].ToString();
             * //        txtButtonText.Text = dr["ButtonText"].ToString();
             * //        txtButtonTitle.Text = dr["ButtonTitle"].ToString();
             * //    }
             * //}
             */
        }