Beispiel #1
0
 private void ButtonRecharge_Click(object sender, EventArgs e)
 {
     try
     {
         if (GlobalClass.Connection.State == ConnectionState.Open)
         {
             GlobalClass.Connection.Close();
         }
         GlobalClass.Connection.Open();
         if (Regex.IsMatch(TextBoxCardNumber.Text, @"2\d{5}") && TextBoxPasswrod.Text != String.Empty)
         {
             SqlCommand    MemberNoCmd = new SqlCommand("select CardNo,Password from Member", GlobalClass.Connection);
             SqlDataReader data        = MemberNoCmd.ExecuteReader();
             int           i           = 0;
             while (data.Read())
             {
                 if (data[0].ToString() == TextBoxCardNumber.Text && data[1].ToString() == GlobalClass.MD5(TextBoxPasswrod.Text))
                 {
                     data.Close();
                     SqlCommand RechargeCmd = new SqlCommand("Recharge", GlobalClass.Connection);
                     RechargeCmd.CommandType = CommandType.StoredProcedure;
                     RechargeCmd.Parameters.Add("@CardNo", SqlDbType.NChar, 6);
                     RechargeCmd.Parameters.Add("@Password", SqlDbType.NChar, 32);
                     RechargeCmd.Parameters.Add("@Balance", SqlDbType.Int);
                     RechargeCmd.Parameters[0].Value = TextBoxCardNumber.Text;
                     RechargeCmd.Parameters[1].Value = GlobalClass.MD5(TextBoxPasswrod.Text);
                     RechargeCmd.Parameters[2].Value = Convert.ToInt32(LabelPrice.Text);
                     if (RechargeCmd.ExecuteNonQuery() == 1)
                     {
                         MessageBox.Show("提交成功,请刷新页面!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                         break;
                     }
                     else
                     {
                         MessageBox.Show("提交失败!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     }
                 }
                 i++;
             }
             GlobalClass.Connection.Close();
         }
         else
         {
             MessageBox.Show("输入不合法!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
             TextBoxCardNumber.Text = String.Empty;
             TextBoxPasswrod.Text   = String.Empty;
             TextBoxCardNumber.Focus();
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
         GlobalClass.Connection.Close();
     }
 }
Beispiel #2
0
 private void ButtonLogin_Click(object sender, EventArgs e)
 {
     if (!Regex.IsMatch(TextBoxAccount.Text, @"1\d{5}"))
     {
         MessageBox.Show("用户名不合法!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
         TextBoxAccount.Clear();
         TextBoxAccount.Focus();
     }
     else if (TextBoxPassword.Text == String.Empty)
     {
         MessageBox.Show("密码不合法!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
         TextBoxPassword.Clear();
         TextBoxPassword.Focus();
     }
     else
     {
         try
         {
             GlobalClass.Connection.Open();
             SqlCommand LoginCmd = new SqlCommand("UserLogin", GlobalClass.Connection);
             LoginCmd.CommandType = CommandType.StoredProcedure;
             LoginCmd.Parameters.Add("@No", SqlDbType.NChar, 6);
             LoginCmd.Parameters.Add("@Password", SqlDbType.NChar, 32);
             LoginCmd.Parameters.Add("@ReturnValue", SqlDbType.Int, 6);
             LoginCmd.Parameters[0].Value     = TextBoxAccount.Text;
             LoginCmd.Parameters[1].Value     = GlobalClass.MD5(TextBoxPassword.Text);
             LoginCmd.Parameters[2].Direction = ParameterDirection.ReturnValue;
             LoginCmd.ExecuteNonQuery();
             int ReturnValue = (int)LoginCmd.Parameters[2].Value;
             GlobalClass.Connection.Close();
             if (ReturnValue == 0)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Administrator;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 1)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Director;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 2)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Manager;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 3)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Reception;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 4)
             {
                 GlobalClass.UserName       = TextBoxAccount.Text;
                 GlobalClass.EmployeeNo     = TextBoxAccount.Text;
                 GlobalClass.PrivilegeLevel = (int)GlobalClass.Privilege.Logistics;
                 this.TimerProgressBar.Start();
             }
             else if (ReturnValue == 5)
             {
                 MessageBox.Show("权限不足!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 TextBoxAccount.Clear();
                 TextBoxPassword.Clear();
                 TextBoxAccount.Focus();
             }
             else if (ReturnValue == 6)
             {
                 MessageBox.Show("密码错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 TextBoxPassword.Clear();
                 TextBoxPassword.Focus();
             }
             else if (ReturnValue == 7)
             {
                 MessageBox.Show("用户名错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 TextBoxAccount.Clear();
                 TextBoxAccount.Focus();
             }
             else
             {
                 MessageBox.Show("未知错误!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
             GlobalClass.Connection.Close();
         }
     }
 }
Beispiel #3
0
 private void ButtonSubmit_Click(object sender, EventArgs e)
 {
     if (TextBoxHandlePerson.Text != String.Empty && TextBoxHandleDate.Text != String.Empty &&
         TextBoxName.Text != String.Empty && (RadioButtonMan.Checked != false || RadioButtonWoman.Checked != false) &&
         TextBoxPassword.Text != String.Empty && TextBoxIDCardNo.Text != String.Empty && TextBoxTel.Text != String.Empty &&
         TextBoxAddress.Text != String.Empty && TextBoxRechargeAmount.Text != String.Empty)
     {
         try
         {
             if (GlobalClass.Connection.State == ConnectionState.Open)
             {
                 GlobalClass.Connection.Close();
             }
             GlobalClass.Connection.Open();
             SqlCommand SubmitCmd = new SqlCommand("SubmitMemberHandle", GlobalClass.Connection);
             SubmitCmd.CommandType = CommandType.StoredProcedure;
             SubmitCmd.Parameters.Add("@CardNo", SqlDbType.NChar, 6);
             SubmitCmd.Parameters.Add("@Password", SqlDbType.NChar, 32);
             SubmitCmd.Parameters.Add("@Name", SqlDbType.NVarChar, 8);
             SubmitCmd.Parameters.Add("@Sex", SqlDbType.NChar, 2);
             SubmitCmd.Parameters.Add("@IDCardNo", SqlDbType.NChar, 18);
             SubmitCmd.Parameters.Add("@Tel", SqlDbType.NChar, 11);
             SubmitCmd.Parameters.Add("@Address", SqlDbType.NVarChar, 32);
             SubmitCmd.Parameters.Add("@HandleDate", SqlDbType.Date);
             SubmitCmd.Parameters.Add("@HandlePerson", SqlDbType.Char, 6);
             SubmitCmd.Parameters.Add("@Balance", SqlDbType.Int);
             SubmitCmd.Parameters.Add("@Remark", SqlDbType.Text);
             SubmitCmd.Parameters[0].Value = (LastNo + 1).ToString() /*TempRef.Text.Substring(7)*/;
             SubmitCmd.Parameters[1].Value = GlobalClass.MD5(TextBoxPassword.Text);
             SubmitCmd.Parameters[2].Value = TextBoxName.Text;
             if (RadioButtonMan.Checked == true)
             {
                 SubmitCmd.Parameters[3].Value = "男";
             }
             else
             {
                 SubmitCmd.Parameters[3].Value = "女";
             }
             SubmitCmd.Parameters[4].Value  = TextBoxIDCardNo.Text;
             SubmitCmd.Parameters[5].Value  = TextBoxTel.Text;
             SubmitCmd.Parameters[6].Value  = TextBoxAddress.Text;
             SubmitCmd.Parameters[7].Value  = TextBoxHandleDate.Text;
             SubmitCmd.Parameters[8].Value  = TextBoxHandlePerson.Text;
             SubmitCmd.Parameters[9].Value  = TextBoxRechargeAmount.Text;
             SubmitCmd.Parameters[10].Value = TextBoxRemark.Text;
             if (SubmitCmd.ExecuteNonQuery() == 1)
             {
                 MessageBox.Show("提交成功,请刷新页面!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 MessageBox.Show("提交失败!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
             GlobalClass.Connection.Close();
         }
     }
     else
     {
         MessageBox.Show("信息不完整!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }
Beispiel #4
0
 private void ButtonSubmit_Click(object sender, EventArgs e)
 {
     if (TextBoxName.Text != String.Empty && (RadioButtonMan.Checked != false || RadioButtonWoman.Checked != false) && TextBoxPassword.Text != String.Empty && ComboBoxPrivilegeLevel.SelectedIndex != 0 &&
         TextBoxPolitical.Text != String.Empty && ComboBoxClass.SelectedIndex != 0 && TextBoxBirthDay.Text != String.Empty && TextBoxIDCardNo.Text != String.Empty && TextBoxNation.Text != String.Empty &&
         TextBoxNativePlace.Text != String.Empty && TextBoxTel.Text != String.Empty && TextBoxAddress.Text != String.Empty && ComboBoxShift.SelectedIndex != 0 && TextBoxSalary.Text != String.Empty &&
         TextBoxBankCardNo.Text != String.Empty && ComboBoxMaritalStatus.SelectedIndex != 0 && TextBoxDateOfEmployment.Text != String.Empty)
     {
         try
         {
             if (GlobalClass.Connection.State == ConnectionState.Open)
             {
                 GlobalClass.Connection.Close();
             }
             GlobalClass.Connection.Open();
             SqlCommand SubmitCmd = new SqlCommand("SubmitEntryHandle", GlobalClass.Connection);
             SubmitCmd.CommandType = CommandType.StoredProcedure;
             SubmitCmd.Parameters.Add("@No", SqlDbType.NChar, 6);
             SubmitCmd.Parameters.Add("@Password", SqlDbType.NChar, 32);
             SubmitCmd.Parameters.Add("@Name", SqlDbType.VarChar, 8);
             SubmitCmd.Parameters.Add("@Sex", SqlDbType.NChar, 2);
             SubmitCmd.Parameters.Add("@Nation", SqlDbType.VarChar, 8);
             SubmitCmd.Parameters.Add("@NativePlace", SqlDbType.VarChar, 16);
             SubmitCmd.Parameters.Add("@Political", SqlDbType.VarChar, 8);
             SubmitCmd.Parameters.Add("@Class", SqlDbType.VarChar, 8);
             SubmitCmd.Parameters.Add("@Shift", SqlDbType.Int);
             SubmitCmd.Parameters.Add("@Salary", SqlDbType.Int);
             SubmitCmd.Parameters.Add("@Tel", SqlDbType.NChar, 11);
             SubmitCmd.Parameters.Add("@Address", SqlDbType.VarChar, 32);
             SubmitCmd.Parameters.Add("@PrivilegeLevel", SqlDbType.Int);
             SubmitCmd.Parameters.Add("@IDCardNo", SqlDbType.NChar, 18);
             SubmitCmd.Parameters.Add("@BankCardNo", SqlDbType.NChar, 19);
             SubmitCmd.Parameters.Add("@BirthDay", SqlDbType.Date);
             SubmitCmd.Parameters.Add("@MaritalStatus", SqlDbType.Int);
             SubmitCmd.Parameters.Add("@DateOfEmployment", SqlDbType.Date);
             SubmitCmd.Parameters[0].Value = (LastNo + 1).ToString();
             SubmitCmd.Parameters[1].Value = GlobalClass.MD5(TextBoxPassword.Text);
             SubmitCmd.Parameters[2].Value = TextBoxName.Text;
             if (RadioButtonMan.Checked == true)
             {
                 SubmitCmd.Parameters[3].Value = "男";
             }
             else
             {
                 SubmitCmd.Parameters[3].Value = "女";
             }
             SubmitCmd.Parameters[4].Value = TextBoxNation.Text;
             SubmitCmd.Parameters[5].Value = TextBoxNativePlace.Text;
             SubmitCmd.Parameters[6].Value = TextBoxPolitical.Text;
             SubmitCmd.Parameters[7].Value = ComboBoxClass.Text;
             if (ComboBoxShift.Text == "日班")
             {
                 SubmitCmd.Parameters[8].Value = 0;
             }
             else if (ComboBoxShift.Text == "夜班")
             {
                 SubmitCmd.Parameters[8].Value = 1;
             }
             SubmitCmd.Parameters[9].Value  = TextBoxSalary.Text;
             SubmitCmd.Parameters[10].Value = TextBoxTel.Text;
             SubmitCmd.Parameters[11].Value = TextBoxAddress.Text;
             SubmitCmd.Parameters[12].Value = ComboBoxPrivilegeLevel.Text;
             SubmitCmd.Parameters[13].Value = TextBoxIDCardNo.Text;
             SubmitCmd.Parameters[14].Value = TextBoxBankCardNo.Text;
             SubmitCmd.Parameters[15].Value = TextBoxBirthDay.Text;
             if (ComboBoxMaritalStatus.Text == "未婚")
             {
                 SubmitCmd.Parameters[16].Value = 0;
             }
             else if (ComboBoxMaritalStatus.Text == "已婚")
             {
                 SubmitCmd.Parameters[16].Value = 1;
             }
             SubmitCmd.Parameters[17].Value = TextBoxDateOfEmployment.Text;
             if (SubmitCmd.ExecuteNonQuery() == 1)
             {
                 MessageBox.Show("提交成功,请刷新页面!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.Close();
             }
             else
             {
                 MessageBox.Show("提交失败!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message, "消息", MessageBoxButtons.OK, MessageBoxIcon.Error);
             GlobalClass.Connection.Close();
         }
     }
     else
     {
         MessageBox.Show("信息不完整!", "消息", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     }
 }