Пример #1
0
        public SettingForm(User user)
        {
            InitializeComponent();
            _user = user;

            dtpTip.DataBindings.Add("Value", Settings.UnfilledDate, "", true, DataSourceUpdateMode.Never);
            tbxDayWH.DataBindings.Add("Text", Settings.WorkingHoursPerDay, "", true, DataSourceUpdateMode.Never);
            txtHourlyPay.DataBindings.Add("Text", Settings.HourlyPay, "", true, DataSourceUpdateMode.Never);

            if (Settings.LaborWageDatabaseFile != string.Empty)
                tbxLaborWageDir.Text = System.IO.Path.GetDirectoryName(Settings.LaborWageDatabaseFile);

            Type t = folderBrowserDialog1.GetType();
            System.Reflection.FieldInfo fi = t.GetField("rootFolder", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
            fi.SetValue(folderBrowserDialog1, (System.Environment.SpecialFolder)0x003d);
        }
Пример #2
0
 public static User GetUser(string username, string password)
 {
     DatabaseSet.�ϥΪ�DataTable datatable = _adapter.GetByUsername_Password(username, password);
     if (datatable.Rows.Count > 0)
     {
         User user = new User();
         user.DataRow = datatable.Rows[0] as DatabaseSet.�ϥΪ�Row;
         return user;
     }
     else
     {
         throw new SWLHMSException("�b���αK�X���~�A���ˬd�᭫�s��J");
     }
 }
Пример #3
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                //�p�G�ϥαb���n�J
                if (true || rbAccount.Checked)
                {
                    //string username = tbxUsername.Text.Trim();
                    string username = this.LoginUserName;

                    string password = tbxPassword.Text.Trim();

                    //�ˬd�O�_����
                    if (username != string.Empty && password != string.Empty)
                    {
                        Regex regex = new Regex("^[A-Za-z0-9]+$");

                        //�ˬd�O�_�]�t�D�k�r��
                        if (regex.IsMatch(username) && regex.IsMatch(password))
                        {
                            _loginUser = User.GetUser(username, password);
                            User.CurrentUser = _loginUser;
                            this.DialogResult = DialogResult.OK;
                        }
                        else
                            throw new SWLHMSException("�b���αK�X�t���D�k�r���A���ˬd�᭫�s��J");
                    }
                    else
                        throw new SWLHMSException("�b���αK�X���o����");
                }
                else
                {
                    _loginUser = User.GetUser("guest", "null");
                    this.DialogResult = DialogResult.OK;
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.ToString());
                MessageBox.Show("�n�J�ɵo�Ϳ��~\n" + ex.Message);
            }
        }