Пример #1
0
 private void btnNext_Click(object sender, EventArgs e)
 {
     if (counter == 0)
     {
         counter = 1;
     }
     else
     {
         bool cntrlCard = Check.ControlCustomer(lblCardNo.Text);
         bool cntrlPass = Check.ControlPassword(lblPassword.Text, lblCardNo.Text);
         if (cntrlCard && cntrlPass)
         {
             List <Customers> csList = GetCustomer.GetAllCustomers();
             foreach (Customers item in csList)
             {
                 if (item.CardNo == lblCardNo.Text)
                 {
                     Form2 frm = new Form2(item);
                     frm.ShowDialog();
                 }
             }
         }
         else
         {
             MessageBox.Show("Password or CardNo is wrong");
         }
     }
 }
Пример #2
0
        public static bool ControlCustomer(string cardNo)
        {
            bool             sonuc  = false;
            List <Customers> csList = GetCustomer.GetAllCustomers();

            foreach (Customers item in csList)
            {
                if (item.CardNo == cardNo)
                {
                    sonuc = true;
                }
            }
            return(sonuc);
        }
Пример #3
0
        private void btnNext_Click(object sender, EventArgs e)
        {
            if (rdbTransfer.Checked)
            {
                if (counter == 0)
                {
                    counter = 1;
                }
                else
                {
                    bool sonuc = Check.ControlCustomer(lblCardNo.Text);
                    if (sonuc)
                    {
                        List <Customers> csList = GetCustomer.GetAllCustomers();
                        foreach (Customers item in csList)
                        {
                            if (item.CardNo == lblCardNo.Text)
                            {
                                List <Accounts> actList = ent.Accounts.Where(t => t.CustomerId == item.CustomerId).ToList();
                                foreach (Accounts act in actList)
                                {
                                    if (cmbAmount.Text != "")
                                    {
                                        int amount = int.Parse(cmbAmount.Text);
                                        act.Money += amount;
                                        this.Close();
                                    }
                                    else
                                    {
                                        MessageBox.Show("Please choose a amount");
                                    }
                                }
                                int result = ent.SaveChanges();
                                if (result > 0)
                                {
                                    MessageBox.Show("Successful");
                                    this.Close();
                                }
                                else
                                {
                                    MessageBox.Show("Error");
                                }
                            }
                        }
                    }
                }
            }
            else if (rdbWithdraw.Checked)
            {
                if (choosedAccount != null)
                {
                    int  amount = int.Parse(cmbAmount.Text);
                    bool sonuc  = Check.ControlMoney(choosedAccount, amount);
                    if (sonuc)
                    {
                        choosedAccount.Money -= amount;
                    }
                    else
                    {
                        MessageBox.Show("Not enough money");
                    }

                    int result = ent.SaveChanges();
                    if (result > 0)
                    {
                        MessageBox.Show("Successful");
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Error");
                    }
                }
            }
            else
            {
                MessageBox.Show("Please choose a operation");
            }
        }