1. 程式人生 > >要點筆記

要點筆記

helper fromfile each object toolstrip tool http ror file

      #region 定時器事件方法
        private void tmMian_Tick(object sender, EventArgs e)
        {
            //當前日期
            sTime.Text = DateTime.Now.ToLongDateString().ToString();
            //當前周期
            ssTime.Text = DateTime.Now.DayOfWeek.ToString();
            //當前時間
            sssTime.Text = DateTime.Now.ToLongTimeString().ToString();
        }
        #endregion

  技術分享圖片

//在主窗體中創建創建一個ShowForm方法,然後在單擊打開新窗體中運用,把主窗體屬性IsMdiContainer改為True.
       #region 顯示子窗體方法
        private void ShowForm(Form form)
        {
            //遍歷所有子窗體
            foreach (Form f in this.MdiChildren)
            {
                if (form.Text == f.Text)
                {
                    f.Activate();
                    return;
                }
            }

            form.MdiParent = this;
            form.Show();
        }
        #endregion    

      //新窗體運用
      #region 客戶管理
     //打開新窗體按鈕 private void toolStripButton1_Click(object sender, EventArgs e) {
       //新窗體 frm=new 新窗體(); FrmCtr frm = new FrmCtr(); ShowForm(frm); } #endregion

  技術分享圖片

//獲取圖片路徑代碼
picHead.Image = Image.FromFile(@"E:\CS構架編程\第六章課程\Work\Car\lmage\客戶.gif");

  

        #region 登錄按鈕
     //登錄切換用戶類型,切換登錄(登錄失敗提示等) private void btnLogin_Click(object sender, EventArgs e) { string s = ""; switch (cboType.Text) { case "客戶": s = "Customer"; break; case "經理": s = "Manager"; break; } string sql = "select LoginPwd from "+s+" where LoginId=@LoginId"; Object o = DBHelper.ExecteScalar(sql, CommandType.Text, new SqlParameter[] { new SqlParameter("@LoginId", txtLoginId.Text) }); if(txtLoginId.Text=="") { MessageBox.Show("登錄賬號不能為空!","登錄提示"); return; } if (txtLoginPwd.Text == "") { MessageBox.Show("登錄密碼不能為空!", "登錄提示"); return; } if (o == null) { MessageBox.Show("你輸入的賬號與類型不一致!", "登錄提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { if (o.ToString() == txtLoginPwd.Text) { if (s == "Manager") { FrmMain frm = new FrmMain(); this.Hide(); frm.Show(); } if(s== "Customer") { FrmCMain frm = new FrmCMain(); this.Hide(); frm.Show(); } } else { MessageBox.Show("登錄失敗,密碼錯誤!", "登錄提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } #endregion技術分享圖片

  

要點筆記