Esempio n. 1
0
        protected virtual void Save()
        {
            Console.WriteLine("Closing and saving");
            DataTable dt = new DataTable();

            dt.Columns.Add("ITEM_LIST", typeof(string));
            dt.Columns.Add("FLAG", typeof(string));
            dt.Columns.Add("SITE", typeof(string));
            dt.Columns.Add("TITLE", typeof(string));

            DataRow dr;

            if (SelectedMultivariateSPCItems != null)
            {
                foreach (SPCItemInfo item in SelectedMultivariateSPCItems)
                {
                    if (item.ItemList == null || item.ItemList == string.Empty)
                    {
                        System.Windows.MessageBox.Show(string.Format("請設定[{0}]中的項目", item.Title),
                                                       "",
                                                       System.Windows.MessageBoxButton.OK,
                                                       System.Windows.MessageBoxImage.Warning);
                        return;
                    }
                    dr = dt.NewRow();
                    dr["ITEM_LIST"] = item.ItemList;
                    dr["FLAG"]      = item.Flag;
                    dr["SITE"]      = SITE_ID;
                    dr["TITLE"]     = item.Title;
                    dt.Rows.Add(dr);
                }
            }


            if (SelectedUnivariateSPCItems != null)
            {
                foreach (SPCItemInfo item in SelectedUnivariateSPCItems)
                {
                    dr = dt.NewRow();
                    dr["ITEM_LIST"] = item.IntItemList;
                    dr["FLAG"]      = item.Flag;
                    dr["SITE"]      = SITE_ID;
                    dr["TITLE"]     = item.Title;
                    dt.Rows.Add(dr);
                }
            }

            SPCItemInfoTable = dt;

            //清除UI結果後關閉
            SelectedMultivariateSPCItems.Clear();
            SelectedUnivariateSPCItems.Clear();
            CloseAction();
        }
        /// <summary>
        /// 覆寫 Save 方法,把原本 Univariate 選項轉為 Multivariate 項目
        /// </summary>
        protected override void Save()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add("ITEM_LIST", typeof(string));
            dt.Columns.Add("FLAG", typeof(string));
            dt.Columns.Add("SITE", typeof(string));
            dt.Columns.Add("TITLE", typeof(string));

            DataRow dr;

            if (SelectedUnivariateSPCItems != null && SelectedUnivariateSPCItems.Count > 1)
            {
                foreach (SPCItemInfo item in SelectedUnivariateSPCItems)
                {
                    dr = dt.NewRow();
                    dr["ITEM_LIST"] = item.IntItemList;
                    dr["FLAG"]      = "T2";
                    dr["SITE"]      = SITE_ID;
                    dr["TITLE"]     = item.Title;
                    dt.Rows.Add(dr);
                }
                dt = dt.Rows.Cast <DataRow>().OrderBy(x => Convert.ToInt16(x["ITEM_LIST"])).CopyToDataTable();
            }
            else
            {
                System.Windows.MessageBox.Show("請輸入至少二項變數做為多變量管制圖", "",
                                               System.Windows.MessageBoxButton.OK,
                                               System.Windows.MessageBoxImage.Warning);
                return;
            }
            SPCItemInfoTable = dt;

            //清除UI結果後關閉
            SelectedMultivariateSPCItems.Clear();
            SelectedUnivariateSPCItems.Clear();
            CloseAction();
        }