コード例 #1
0
 public void Interest(EmpFields emp)
 {
     Console.Write("Enter your Id : ");
     emp.AccId = Convert.ToInt32(Console.ReadLine());
     result    = Search(emp.AccId, con);
     string[] tokens = result.Split(',');
     balance = Convert.ToInt32(tokens[0]);
     if (balance < 0)
     {
         Console.WriteLine(" No record found with this Account Id. Please try again....");
     }
     else
     {
         AccType = tokens[1];
         char[] ch = AccType.ToCharArray();
         AccType = ch[0] + "";
         float simpleInterest = 0;
         if (AccType == "s")
         {
             simpleInterest = (balance * 4 * 1) / 100;
             Console.WriteLine("Interest is: {0} Rs per Year", simpleInterest);
         }
         else if (AccType == "c")
         {
             simpleInterest = (balance * 1 * 1) / 100;
             Console.WriteLine("Interest is: {0} Rs per Year", simpleInterest);
         }
         else
         {
             Console.WriteLine("Interest cannot be appliet on DMAT's Account");
         }
     }
 }
コード例 #2
0
 public void Interest(employee emp)
 {
     try
     {
         Console.Write("Enter your Id : ");
         emp.id  = Convert.ToInt32(Console.ReadLine());
         balance = Convert.ToInt32(bankingEntities.employees.Find(emp.id).balance);
         result  = Convert.ToString(bankingEntities.employees.Find(emp.id).accountType);
         Console.WriteLine("Your available balance is : {0}", balance);
         AccType = result;
         char[] ch = AccType.ToCharArray();
         AccType = ch[0] + "";
         float simpleInterest = 0;
         if (AccType == "s")
         {
             simpleInterest = (balance * 4 * 1) / 100;
             Console.WriteLine("Interest is: {0} Rs per Year", simpleInterest);
         }
         else if (AccType == "c")
         {
             simpleInterest = (balance * 1 * 1) / 100;
             Console.WriteLine("Interest is: {0} Rs per Year", simpleInterest);
         }
         else
         {
             Console.WriteLine("Interest cannot be appliet on DMAT's Account");
         }
     }
     catch (Exception e)
     {
         Console.WriteLine(" No record found with this Account Id. Please try again....");
     }
 }
コード例 #3
0
 public void Withdraw(EmpFields emp)
 {
     //int bal = emp.balance;
     Console.Write("Enter your Id : ");
     emp.AccId = Convert.ToInt32(Console.ReadLine());
     result    = Search(emp.AccId, con);
     string[] tokens = result.Split(',');
     balance = Convert.ToInt32(tokens[0]);
     if (balance < 0)
     {
         Console.WriteLine(" No record found with this Account Id. Please try again....");
     }
     else
     {
         Console.WriteLine("Your available balance is : {0}", balance);
         AccType = tokens[1];
         char[] ch = AccType.ToCharArray();
         AccType = ch[0] + "";
         Console.WriteLine("Enter the amount you want to withdraw ");
         int draw = Convert.ToInt32(Console.ReadLine());
         if (AccType == "s")
         {
             if ((balance - draw) < 1000)
             {
                 Console.WriteLine("Minimum Balance in savings account must be 1000 Rs. Please withdraw some less amount.");
             }
             else
             {
                 balance = balance - draw;
             }
         }
         else if (AccType == "c")
         {
             if ((balance - draw) < 0)
             {
                 Console.WriteLine("Minimum Balance in current account must be 0 Rs. Please withdraw some less amount.");
             }
             else
             {
                 balance = balance - draw;
             }
         }
         else
         {
             if ((balance - draw) < -10000)
             {
                 Console.WriteLine("Minimum Balance in current account must be -10000 Rs. Please withdraw some less amount.");
             }
             else
             {
                 balance = balance - draw;
             }
         }
     }
     Update(balance, con, emp.AccId);
 }
コード例 #4
0
 public void Withdraw(employee emp)
 {
     //int bal = emp.balance;
     Console.Write("Enter your Id : ");
     emp.id = Convert.ToInt32(Console.ReadLine());
     try
     {
         balance = Convert.ToInt32(bankingEntities.employees.Find(emp.id).balance);
         result  = Convert.ToString(bankingEntities.employees.Find(emp.id).accountType);
         Console.WriteLine("Your available balance is : {0}", balance);
         AccType = result;
         char[] ch = AccType.ToCharArray();
         AccType = ch[0] + "";
         Console.WriteLine("Enter the amount you want to withdraw ");
         int draw = Convert.ToInt32(Console.ReadLine());
         if (AccType == "s")
         {
             if ((balance - draw) < 1000)
             {
                 Console.WriteLine("Minimum Balance in savings account must be 1000 Rs. Please withdraw some less amount.");
             }
             else
             {
                 balance = balance - draw;
             }
         }
         else if (AccType == "c")
         {
             if ((balance - draw) < 0)
             {
                 Console.WriteLine("Minimum Balance in current account must be 0 Rs. Please withdraw some less amount.");
             }
             else
             {
                 balance = balance - draw;
             }
         }
         else
         {
             if ((balance - draw) < -10000)
             {
                 Console.WriteLine("Minimum Balance in current account must be -10000 Rs. Please withdraw some less amount.");
             }
             else
             {
                 balance = balance - draw;
             }
         }
         bankingEntities.employees.Find(emp.id).balance = balance;
         bankingEntities.SaveChanges();
     }
     catch (Exception e)
     {
         Console.WriteLine(" No record found with this Account Id. Please try again....");
     }
 }