Esempio n. 1
0
 public DataTable ListTxnByUser(string userID)
 {
     return(daoTXN.ListTxnByUser(userID));
 }
Esempio n. 2
0
        public FormMain()
        {
            InitializeComponent();
            TXN       daoTXN = new TXN();
            DataTable dt     = new DataTable();

            if (GlobalInfo.USER_ID == GlobalDaoSetting.GetConnectionInfo.ConnectionName)
            {
                dt = Task.Run(() => daoTXN.ListData()).Result;
            }
            else
            {
                dt = Task.Run(() => daoTXN.ListTxnByUser(GlobalInfo.USER_ID)).Result;
                //dt = Task.Run(() => daoTXN.ListData()).Result;
            }
            string[] maintainItem = new string[] { "20110", "20112", "20130", "20140", "20220", "20230", "20231"
                                                   , "20232", "20233", "20310", "20320", "20330", "20340", "20410"
                                                   , "20420", "20430", "25010", "28110", "28510", "28511", "28512"
                                                   , "28610", "28620", "28630", "40070", "40080", "49010", "49020"
                                                   , "49030", "49040", "49050", "49060", "49061", "49062", "49070"
                                                   , "49080", "50073", "50120", "51010", "51020", "51030", "51040"
                                                   , "51050", "51060", "51070", "S0011", "S0012", "S0070", "S0071"
                                                   , "S0072", "S0073", "30201", "30202", "30203", "30204", "30205"
                                                   , "30220", "30221", "30222", "30223", "30224", "30290" };

            AccordionControlElement item = null;
            string txnId     = "";
            string txnName   = "";
            string txnExtend = "";
            string txnParent = "";

            //全部作業
            foreach (var group in accordionMenu.Elements)
            {
                string groupTag = group.Tag.ToString().ToUpper();


                var result = from x in dt.AsEnumerable()
                             where x.Field <String>("TXN_ID").Substring(0, 1) == groupTag ||
                             (x.Field <String>("TXN_ID").Substring(0, 2) == "ND" &&
                              x.Field <String>("TXN_ID").Substring(2, 1) == groupTag)
                             orderby x.Field <Int16>("TXN_SEQ_NO")
                             select x;

                //各系列作業
                foreach (DataRow row in result)
                {
                    txnId     = row["TXN_ID"].ToString().Trim();
                    txnName   = row["TXN_NAME"].ToString().Trim();
                    txnExtend = row["TXN_EXTEND"].ToString().Trim();
                    txnParent = row["TXN_PARENT_ID"].ToString().Trim();
                    //一階項目
                    if (txnId.Substring(0, 2) != "ND" && txnParent == groupTag)
                    {
                        item = new AccordionControlElement()
                        {
                            Text = string.Format("{0} {1}", txnId, txnName),
                            Tag  = new ItemData()
                            {
                                TXN_ID = txnId, TXN_NAME = txnName
                            },
                            Style = ElementStyle.Item
                        };
                    }
                    //二階項目先跳過
                    else if (txnParent != groupTag)
                    {
                        continue;
                    }
                    //一階節點
                    else
                    {
                        item = new AccordionControlElement()
                        {
                            Text = string.Format("{0}", txnName),
                            Tag  = new ItemData()
                            {
                                TXN_ID = txnId, TXN_NAME = txnName
                            },
                            Style = ElementStyle.Group
                        };
                        if (txnExtend == "Y")
                        {
                            item.Expanded = true;
                        }
                        //放入子項目(二階)
                        foreach (DataRow dr in result)
                        {
                            string parent = dr["TXN_PARENT_ID"].ToString().Trim();
                            string Id     = dr["TXN_ID"].ToString().Trim();
                            string name   = dr["TXN_NAME"].ToString().Trim();
                            string level  = dr["TXN_LEVEL"].ToString().Trim();
                            AccordionControlElement subItem = null;
                            if (Id.Substring(0, 2) == "ND")
                            {
                                subItem = new AccordionControlElement()
                                {
                                    Text = string.Format("{0}", name),
                                    Tag  = new ItemData()
                                    {
                                        TXN_ID = Id, TXN_NAME = name
                                    },
                                    Style = ElementStyle.Group
                                };
                            }
                            else
                            {
                                subItem = new AccordionControlElement()
                                {
                                    Text = string.Format("{0} {1}", Id, name),
                                    Tag  = new ItemData()
                                    {
                                        TXN_ID = Id, TXN_NAME = name
                                    },
                                    Style = ElementStyle.Item
                                };
                            }
                            if (parent == txnId)
                            {
                                item.Elements.Add(subItem);
                            }
                            //Austin 正式環境不可點選維護作業
                            if (GlobalDaoSetting.GetConnectionInfo.ConnectionName == "CI")
                            {
                                if (maintainItem.Contains(Id))
                                {
                                    subItem.Enabled = false;
                                }
                            }
                        }
                    }

                    group.Elements.Add(item);
                    //Austin 正式環境不可點選維護作業
                    if (GlobalDaoSetting.GetConnectionInfo.ConnectionName == "CI")
                    {
                        if (maintainItem.Contains(txnId))
                        {
                            item.Enabled = false;
                        }
                    }
                }//foreach (DataRow row in result)
                if (group.Elements.Count == 0)
                {
                    group.Visible = false;
                }

                //放入父階層
                //foreach (DataRow row in result) {
                //    txnParent = row["TXN_PARENT_ID"].ToString().Trim();
                //    txnName = row["TXN_NAME"].ToString().Trim();
                //    if (txnParent.Length>1&&txnParent.Substring(0, 2) == "ND") {
                //        item = new AccordionControlElement() {
                //            Text = string.Format("{0} {1}", txnId, txnName),
                //            Tag = new ItemData() { TXN_ID = txnId, TXN_NAME = txnName },
                //            Style = ElementStyle.Item
                //        };
                //        group.Elements[txnParent].AccordionControl.Elements.Add(item);
                //    }
                //}
            }//foreach (var group in accordionMenu.Elements)

            toolStripStatusLabelServerName.Text = GlobalDaoSetting.GetConnectionInfo.ConnectionName;
            toolStripStatusLabelDBName.Text     = GlobalDaoSetting.Database;
            toolStripStatusLabelUserName.Text   = GlobalInfo.USER_NAME;
            //toolStripStatusLabelVersionNum.Text = new DateTime(2000,1,1).AddDays(Assembly.GetExecutingAssembly().GetName().Version.Build).ToString("yyyy/MM/dd");
            toolStripStatusLabelVersionNum.Text = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            this.Text = "交易資訊統計管理系統";
            if (GlobalDaoSetting.GetConnectionInfo.ConnectionName != "CI")
            {
                this.Text += " (測試)";
            }
        }