Example #1
0
        // Method to handle user login validation, obtain user
        // information, and redirect client following login attempt.
        protected void EquipCheckLoginCtrl_Authenticate(object sender, AuthenticateEventArgs e)
        {
            EquipCheckAppUser user = new EquipCheckAppUser();

            user.Username = EquipCheckLoginCtrl.UserName;
            user.Password = EquipCheckLoginCtrl.Password;

            UserManager       userMgr      = new UserManager();
            EquipCheckAppUser userAtServer = userMgr.RetrieveUser(user);

            if (userAtServer != null)
            {
                e.Authenticated = true;

                EquipCheckAppUser userLocal = userMgr.RetrieveLocalUser(userAtServer);

                if (userLocal == null)
                {
                    userLocal = userMgr.CreateUser(userAtServer);
                    userLocal = ListCreation.CreateLists(userLocal);
                }

                // Get user's checklists
                CheckListManager checkListManager = new CheckListManager();
                List <CheckList> checkLists       = checkListManager.RetrieveCheckLists(userLocal);
                List <String>    checkListNames   = checkListManager.getCheckListNames(checkLists);

                userLocal.AllCheckList      = checkLists;
                userLocal.AllCheckListNames = checkListNames;

                // Get user's equipment lists
                EquipListManager     equipListManager = new EquipListManager();
                List <EquipmentList> equipLists       = equipListManager.RetrieveEquipLists(userLocal);

                if (equipLists == null || equipLists.Count == 0)
                {
                    userLocal = ListCreation.CreateLists(userLocal);
                }
                else
                {
                    List <String> equipListNames = equipListManager.getEquipmentListNames(equipLists);
                    userLocal.AllEquipLists     = equipLists;
                    userLocal.AllEquipListNames = equipListNames;
                }

                Session["user"] = userLocal;

                Response.Redirect("/Restricted/Welcome.aspx");
            }
            else
            {
                e.Authenticated = false;

                Session["user"]         = null;
                Session["message_type"] = "login_error";
                Session["message"]      = "Login Error.";
                Session["details"]      = "User Credentials Invalid.";
                Response.Redirect("/Restricted/Message.aspx");
            }
        }
 private void btnClearCheckListDB_Click(object sender, EventArgs e)
 {
     if (MessageBox.Show("警告!是否确定要清空交割单数据库?", "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning) == DialogResult.OK)
     {
         CheckListManager manager = new CheckListManager();
         int count = manager.DeleteAll();
         MessageBox.Show(string.Format("Done! Deteled {0} lines.", count));
     }
 }
        private void btnImportCheckList_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                CheckListManager manager = new CheckListManager();
                //int count1 = manager.ImportFromXls(@"D:\stockdata\20150726 交割单查询.xls");
                //int count2 = manager.ImportFromTxt(@"D:\stockdata\20150911 交割单查询.txt", 1, @"\t", new string[] { "=", "\"" });
                //int count3 = manager.ImportFromTxt(@"D:\stockdata\20151016 交割单查询.txt", 1, @"\t", new string[] { "=", "\"" });
                //MessageBox.Show(string.Format("Done! Inserted {0} lines.", count1 + count2 + count3));

                //根据文件扩展名,选择读取程序
                //string expStr = ofd.FileName.Substring(ofd.FileName.LastIndexOf('.'));
                string expStr = System.IO.Path.GetExtension(ofd.FileName);
                int    count  = 0;
                try
                {
                    if (expStr.ToLower() == ".xlsx" || expStr.ToLower() == ".xls")
                    {
                        count = manager.ImportFromXls(ofd.FileName);
                    }
                    else if (expStr.ToLower() == ".txt")
                    {
                        count = manager.ImportFromTxt(ofd.FileName, 1, @"\t", new string[] { "=", "\"" });
                    }
                    else
                    {
                        MessageBox.Show("请选择txt或者xlsx文件。");
                        return;
                    }
                }
                catch (NPOI.POIFS.FileSystem.NotOLE2FileException)
                {
                    MessageBox.Show("文件格式错误!文件的格式与文件扩展名指定的格式不一致。请尝试另存为。");
                    return;
                    //throw;
                }
                string p = new PortfolioGenerater().PGenerater();
                string a = new AccountStatusGenerater().AGenerater();
                MessageBox.Show(string.Format("Done! Inserted {0} lines." + "\n" + p.ToString() + "\n" + a.ToString(), count));

                //查询checklist数据库的最大日期,并显示在文本框中
                if (manager.GetCount() == 0)
                {
                    this.txtMaxDate.Text = "There is no checklist.";
                }
                else
                {
                    this.txtMaxDate.Text = manager.GetMaxDate().ToShortDateString();
                }
            }
        }
Example #4
0
        //更新自定义控件UCtlTradingTrace
        public void UpdateUCtlTradingTrace(string code)
        {
            this.txtStockCode.Text = code;

            //查询交易记录
            List <CheckList> checkListData = new CheckListManager().GetByCode(code).ToList <CheckList>();

            this.dgvCheckList.DataSource = checkListData;

            //设置图形数据
            this.SetDataToChartCandel(code);
        }
        private void UCtlConfiguration_Load(object sender, EventArgs e)
        {
            //查询checklist数据库的最大日期,并显示在文本框中
            CheckListManager manager = new CheckListManager();

            if (manager.GetCount() == 0)
            {
                this.txtMaxDate.Text = "There is no checklist.";
            }
            else
            {
                this.txtMaxDate.Text = manager.GetMaxDate().ToShortDateString();
            }
        }
Example #6
0
        private void btnRefreshData_Click(object sender, EventArgs e)
        {
            string code   = this.txtStockCode.Text;
            bool   traded = new CheckListManager().HasBeenTraded(code);

            if (traded == true)
            {
                List <CheckList> checkListData   = new CheckListManager().GetByCode(code).ToList <CheckList>();
                DateTime         updateBeginDate = checkListData[0].Date.AddDays(-30);
                DateTime         updateEndDate   = checkListData[checkListData.Count - 1].Date.AddDays(30);
                new StockDayPriceManager().AutoUpdateByCodeName(code, checkListData[0].Name, updateBeginDate, updateEndDate);
                //设置图形数据
                this.SetDataToChartCandel(code);
            }
        }
        // Method to save the user's Equipment Checklist.
        protected void SaveChecklistButton_Click(object sender, EventArgs e)
        {
            CheckList checkList = new CheckList();

            checkList.CheckListName        = ChecklistNameTextBox.Text;
            checkList.CheckListDesc        = ChecklistDescriptionTextBox.Text;
            checkList.TripName             = TripNameTextBox.Text;
            checkList.TripDesc             = TripDescriptionTextBox.Text;
            checkList.TripDate             = TripDateTextBox.Text;
            checkList.CheckListItemSummary = ChecklistItemsTextBox.Text;

            if (checkList.Validate())
            {
                EquipCheckAppUser user       = (EquipCheckAppUser)Session["user"];
                List <CheckList>  checkLists = user.AllCheckList;

                CheckListManager checkListManager = new CheckListManager();
                checkListManager.CreateCheckList(user, checkList);

                checkLists.Add(checkList);
                user.AllCheckList = checkLists;

                List <String> checkListNames = user.AllCheckListNames;
                checkListNames.Add(checkList.CheckListName);
                user.AllCheckListNames = checkListNames;

                Session["user"]             = user;
                Session["checkListEntries"] = null;
                Session["selectedItems"]    = null;
                Session["selectedItemsWithDescriptions"] = null;

                Session["message_type"] = "checklist_success";
                Session["message"]      = "Checklist Creation Successful.";
                Session["details"]      = "Click OK to Continue!";
            }
            else
            {
                saveChecklistEntries();
                Session["message_type"] = "checklist_error";
                Session["message"]      = "Checklist Entry Error.";
                Session["details"]      = "Checklist Name and Description are Required!";
            }

            Response.Redirect("/Restricted/Message.aspx");
        }
 private void Awake()
 {
     instance = this;
 }