private void button1_Click(object sender, EventArgs e) { if (radioButton1.Checked == true) { language = true; } else { language = false; } List <Account> AccountLists = AccountList.GetAllAccount(); foreach (Account acc in AccountLists) { if (textBox1.Text.Equals(acc.UserName) && textBox2.Text.Equals(acc.Pass) && acc.Rule == 1) { AdminForm admin = new AdminForm("Admin : " + acc.UserName, this); admin.Show(); break; } else { MessageBox.Show("UserName or Pass was wrong ! Please try again."); break; } } }
protected void Page_Load(object sender, EventArgs e) { CashFlowInfo ci = (CashFlowInfo)Session["CashierDetail"]; happenDate.Text = ci.HappenDate.ToShortDateString(); projectCode.Text = ci.ProjectCode; projectAccount.Text = ci.ProjectAccount; cashType.Text = ci.CashType; income.Text = ci.Income.ToString(); expense.Text = ci.Expense.ToString(); department.Text = ci.Department; summary.Text = ci.Summary; handler.Text = ci.Handler; if (!IsPostBack) { DataSet allAcc = AccountList.GetAllAccount(); accountIDList.DataSource = allAcc.Tables[0].DefaultView; accountIDList.DataTextField = "AccountName"; accountIDList.DataValueField = "AccountName"; accountIDList.DataBind(); } }
private void button1_Click(object sender, EventArgs e) { string error = ""; string FullName = textBox1.Text; DateTime DOB = dateTimePicker1.Value; string Email = textBox3.Text; string Phone = textBox4.Text; string AccountName = textBox5.Text; string Pass = textBox6.Text; string cofirmPass = textBox7.Text; //Full name if (FullName == null || FullName.Length == 0) { error = error + "Full Name cant blank.\n"; } //email if (Email == null || Email.Length == 0) { error = error + "Full Email cant blank.\n"; } Regex emailRegex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$"); Match match1 = emailRegex.Match(Email); if (!match1.Success) { error = error + "Email is incorrect.\n"; } //phone if (Phone == null || Phone.Length == 0) { error = error + "Full Phone cant blank.\n"; } Regex phoneRegex = new Regex(@"^[0]\d{9,10}"); Match match2 = phoneRegex.Match(Phone); if (!match2.Success) { error = error + "Phone is incorrect.\n"; } //account Name if (AccountName == null || AccountName.Length == 0) { error = error + "Full Account Name cant blank.\n"; } if (AccountName.Length > 100) { error = error + "Account Name cant bigger than 150 character.\n"; } //pass if (Pass == null || Pass.Length == 0) { error = error + "Full Password cant blank.\n"; } if (cofirmPass == null || cofirmPass.Length == 0) { error = error + "Full Confirm cant blank.\n"; } if (!(Pass.Equals(cofirmPass))) { error = error + "Confirm Password diffirent Password.\n"; } foreach (Account acc in AccountList.GetAllAccount()) { if (AccountName.Equals(acc.UserName)) { error = error + "Account Name is exits.\n"; } } addJournalist(error, FullName, DOB, Email, Phone, AccountName, Pass); }