private void search_word_Click(object sender, EventArgs e) { List <Customer_DATA> list = new List <Customer_DATA>(); list = Customer_BLL.Select_ALL_Customers().Where (x => (x.First_Name.Contains(search.Text) || search.Text == "") || (x.Last_Name.Contains(search.Text) || search.Text == "") || (x.Tel.Contains(search.Text) || search.Text == "") || (x.Email.Contains(search.Text) || search.Text == "") || (search.Text.Contains(x.First_Name + " " + x.Last_Name)) ).ToList(); DataTable table = new DataTable(); table.Columns.Add("id"); table.Columns.Add("name"); table.Columns.Add("last name"); table.Columns.Add("phone"); table.Columns.Add("email"); table.Columns.Add("image", typeof(byte[])); foreach (var item in list) { table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image); count_ALL_items++; } bmb = BindingContext[table]; dataGridView1.DataSource = table; dataGridView1.Columns[5].Visible = false; }
private void delete_Click(object sender, EventArgs e) { DataGridViewRow row = dataGridView1.SelectedRows[0]; Customer_DATA castumer = new Customer_DATA(); castumer.ID = Convert.ToInt16(row.Cells[0].Value); Customer_BLL.Delete_Customers(castumer); List <Customer_DATA> customer = new List <Customer_DATA>(); customer = Customer_BLL.Select_ALL_Customers(); DataTable table = new DataTable(); table.Columns.Add("id"); table.Columns.Add("name"); table.Columns.Add("last name"); table.Columns.Add("phone"); table.Columns.Add("email"); table.Columns.Add("image", typeof(byte[])); foreach (var item in customer) { table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image); } dataGridView1.DataSource = table; dataGridView1.Columns[5].Visible = false; }
private void update_Click(object sender, EventArgs e) { int current_count; current_count = count; DataGridViewRow row = dataGridView1.SelectedRows[0]; Customer_DATA castumer = new Customer_DATA(); castumer.ID = Convert.ToInt16(row.Cells[0].Value); castumer.First_Name = name.Text; castumer.Last_Name = surname.Text; castumer.Tel = phone.Text; castumer.Email = email.Text; MemoryStream memory = new MemoryStream(); image.Image.Save(memory, image.Image.RawFormat); byte[] byte_image = memory.ToArray(); castumer.Image = byte_image; Customer_BLL.Update_Customers(castumer); List <Customer_DATA> customer = new List <Customer_DATA>(); customer = Customer_BLL.Select_ALL_Customers(); DataTable table = new DataTable(); table.Columns.Add("id"); table.Columns.Add("name"); table.Columns.Add("last name"); table.Columns.Add("phone"); table.Columns.Add("email"); table.Columns.Add("image", typeof(byte[])); foreach (var item in customer) { table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image); } dataGridView1.DataSource = table; dataGridView1.Columns[5].Visible = false; bmb = BindingContext[table]; bmb.Position = current_count; }
/*Method for noraml cash withdraw*/ public void normalCash(Customer_BO customer) { while (true) { Console.Clear(); try { WriteLine("Enter the withdrawal amount: "); int money = System.Convert.ToInt32(ReadLine()); if (money < 0) { throw new Exception(); } Customer_BLL customer_BLL = new Customer_BLL(); (bool, bool, bool)data = customer_BLL.cashWithdraw(customer, money); bool result = data.Item1; bool daily_tr = data.Item2; bool low_balance = data.Item3; if (result == true) { showTransactionResult(result, customer, money);//function show result of transcation } if (daily_tr == true) { WriteLine("Daily transaction limit is 20000. you can't go beyond this limit."); } if (money > 20000) { WriteLine("Transaction amount should be less than 20000."); } if (low_balance == true) { WriteLine("Your account balance is low for this transaction"); } break; } catch (Exception) { WriteLine("Input is not correct Select corect amount. Press any key to continue."); ReadKey(); WriteLine(""); } } }
private void add_Click(object sender, EventArgs e) { Customer_DATA castumer = new Customer_DATA(); castumer.First_Name = name.Text; castumer.Last_Name = surname.Text; castumer.Tel = phone.Text; castumer.Email = email.Text; MemoryStream memory = new MemoryStream(); image.Image.Save(memory, image.Image.RawFormat); byte[] byte_image = memory.ToArray(); castumer.Image = byte_image; Customer_BLL.Insert_Customers(castumer); List <Customer_DATA> customer = new List <Customer_DATA>(); customer = Customer_BLL.Select_ALL_Customers(); DataTable table = new DataTable(); table.Columns.Add("id"); table.Columns.Add("name"); table.Columns.Add("last name"); table.Columns.Add("phone"); table.Columns.Add("email"); table.Columns.Add("image", typeof(byte[])); foreach (var item in customer) { table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image); } dataGridView1.DataSource = table; dataGridView1.Columns[5].Visible = false; add.Enabled = false; add_new.Enabled = true; bmb = BindingContext[table]; bmb.Position = count_ALL_items; }
private void show_orders_Load(object sender, EventArgs e) { DataTable table = new DataTable(); table.Columns.Add("رقم الفاتورة"); table.Columns.Add("التاريخ"); table.Columns.Add("Id_customer"); table.Columns.Add("الاسم الاول"); table.Columns.Add("الاسم الثاني"); table.Columns.Add("ID_User"); table.Columns.Add("قيمة الفاتورة"); List <Orders_DATA> list_order = new List <Orders_DATA>(); list_order = Orders_BLL.Select_ALL_Orders(); foreach (var item in list_order) { // List<Order_Details_DATA> Order_Detail = new List<Order_Details_DATA>(); item.Customer = Customer_BLL.Select_Item_Customers(item.Customer); // Order_Detail = Order_Details_DAL.Select_ALL_Order_Details_By_Products_Id(item.Id); table.Rows.Add(item.Id, item.Order_date, item.Customer.ID, item.Customer.First_Name, item.Customer.Last_Name, item.User_id, item.Total_paied); } dataGridView1.DataSource = table; dataGridView1.Columns[2].Visible = false; dataGridView1.Columns[5].Visible = false; }
private void Form_select_customer_Load(object sender, EventArgs e) { List <Customer_DATA> customer = new List <Customer_DATA>(); customer = Customer_BLL.Select_ALL_Customers(); DataTable table = new DataTable(); table.Columns.Add("id"); table.Columns.Add("name"); table.Columns.Add("last name"); table.Columns.Add("phone"); table.Columns.Add("email"); table.Columns.Add("image", typeof(byte[])); foreach (var item in customer) { table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image); } dataGridView1.DataSource = table; dataGridView1.Columns[5].Visible = false; }
/*method to deposite cash in account*/ public void depositCash(Customer_BO customer) { bool m_l_break = false; while (true) { Console.Clear(); int amount; bool l_break = false; try { amount = inputInt("Enter the cash amount to deposit: "); if (amount < 1) { Write("Enter correct amount "); throw new Exception(); } Customer_BLL customer_BLL = new Customer_BLL(); bool result = customer_BLL.deposite(customer, amount); if (result == true) { WriteLine("Cash Deposited Successfully."); while (true) { try { Write("Do you wish to print a receipt(Y / N) ? "); char answer = System.Convert.ToChar(ReadLine()); if (answer == 'y' || answer == 'Y') { Console.Clear(); showRecepit(customer, "Cash Deposite", amount); WriteLine("Press any key to continue"); ReadKey(); l_break = true; m_l_break = true; } else if (answer == 'n' || answer == 'Y') { WriteLine(""); l_break = true; m_l_break = true; } else { throw new Exception(); } if (l_break == true) { break; } } catch (Exception) { WriteLine("Input is not correct. Please select Y|N"); } } } else { WriteLine("Transaction cannot completed"); } } catch (Exception) { WriteLine("Input is not correct Press any key to continue"); ReadKey(); WriteLine(""); } if (m_l_break == true) { break; } } }
/*Method for cash transfer from one account to another*/ public void cashTransfer(Customer_BO depositor) { bool m_loop = false; bool l_break = false; Customer_BO customer = new Customer_BO(); Customer_BLL customer_BLL = new Customer_BLL(); while (true) { Console.Clear(); try { int amount = inputInt("Enter amount in multiples of 500: "); if (amount % 500 != 0 || amount < 0) { Write("Enter correct amount "); throw new Exception(); } int accountNO = inputInt("\nEnter the account number to which you want to transfer: "); if (accountNO < 1) { Write("Please enter valid AccountNo "); throw new Exception(); } customer = customer_BLL.giveAccount(accountNO); int accountNO2 = -1;//beacuse account numbr is never -ve try { Write($"\nYou wish to deposit Rs {amount} in account held by Mr. {customer.holderName};" + $" If this information is correct please re - enter the account number: "); accountNO2 = System.Convert.ToInt32(ReadLine()); } catch (Exception) { } if (accountNO == accountNO2) { if (customer_BLL.Transfer(depositor, customer, amount) == true) { WriteLine("Transaction confirmed."); } } else { WriteLine("Account Number is wrong"); l_break = true; m_loop = true; } while (l_break != true) { try { Write("Do you wish to print a receipt(Y / N)? "); char answer = System.Convert.ToChar(ReadLine()); if (answer == 'y' || answer == 'Y') { Console.Clear(); showRecepit(depositor, "Cash Transfer", amount); l_break = true; m_loop = true; } else { WriteLine(""); l_break = true; m_loop = true; } if (l_break == true) { break; } } catch (Exception) { WriteLine("Input is not correct Select corect amount."); } } } catch (Exception) { WriteLine("Input is not correct Press any key to continue"); ReadKey(); } if (m_loop == true) { break; } } }
/*Method for fast cash withdraw*/ public void fastCash(Customer_BO customer) { bool m_loop = false; while (true) { Console.Clear(); Customer_BLL customer_BLL = new Customer_BLL(); int denomination = 0; int money = 0; char confirmation = ' '; bool i_loop1 = false; WriteLine("1----500"); WriteLine("2----1000"); WriteLine("3----2000"); WriteLine("4----5000"); WriteLine("5----10000"); WriteLine("6----15000"); WriteLine("7----20000"); WriteLine("Select one of the denominations of money: "); try { denomination = System.Convert.ToInt32(ReadLine()); switch (denomination) { case 1: money = 500; m_loop = true; break; case 2: money = 1000; m_loop = true; break; case 3: money = 2000; m_loop = true; break; case 4: money = 5000; m_loop = true; break; case 5: money = 10000; m_loop = true; break; case 6: money = 15000; m_loop = true; break; case 7: money = 20000; m_loop = true; break; } if (denomination > 0 && denomination < 7) { while (i_loop1 != true) { try { WriteLine($"Are you sure you want to withdraw Rs.{money}(Y / N) ? "); confirmation = System.Convert.ToChar(ReadLine()); if (confirmation == 'Y' || confirmation == 'y') { (bool, bool, bool)data = customer_BLL.cashWithdraw(customer, money); bool result = data.Item1; bool daily_tr = data.Item2; bool low_balance = data.Item3; if (result == true) { showTransactionResult(result, customer, money); } if (daily_tr == true) { WriteLine("Daily transaction limit is 20000. you can't go beyond this limit."); } if (money > 20000) { WriteLine("Transaction amount should be less than 20000."); } if (low_balance == true) { WriteLine("Your account balance is low for this transaction"); } i_loop1 = true; } else if (confirmation == 'n' || confirmation == 'N') { WriteLine("Cash is not withdrawal"); i_loop1 = true; } else { WriteLine("Input is not correct select Y|N "); } } catch (Exception) { WriteLine("Input is not correct Please select Y|N "); } } } else { WriteLine("Invalid input Please select above denomination. Press any key to continue."); ReadKey(); Console.Clear(); } } catch (Exception) { WriteLine("Input is not correct Select Above denominations. Press any key to continue."); ReadKey(); } if (m_loop == true) { break; } } }
private void button2_Click(object sender, EventArgs e) { DataTable table = new DataTable(); table.Columns.Add("رقم الفاتورة"); table.Columns.Add("التاريخ"); table.Columns.Add("Id_customer"); table.Columns.Add("الاسم الاول"); table.Columns.Add("الاسم الثاني"); table.Columns.Add("ID_User"); table.Columns.Add("قيمة الفاتورة"); List <Orders_DATA> list_order = new List <Orders_DATA>(); list_order = Orders_BLL.Select_ALL_Orders(); foreach (var item in list_order) { item.Customer = Customer_BLL.Select_Item_Customers(item.Customer); } list_order = list_order.Where(x => (x.Customer.First_Name.Contains(search.Text) || search.Text == "") || (x.Customer.Last_Name.Contains(search.Text) || search.Text == "") || (x.Id.ToString().Contains(search.Text) || search.Text == "") || (search.Text.Contains(x.Customer.First_Name + " " + x.Customer.Last_Name)) ).ToList(); list_order = list_order.Where(x => (x.Order_date.ToString().Contains(dateTimePicker1.Value.Date.ToString()))).ToList(); foreach (var item in list_order) { List <Order_Details_DATA> Order_Detail = new List <Order_Details_DATA>(); item.Customer = Customer_BLL.Select_Item_Customers(item.Customer); Order_Detail = Order_Details_DAL.Select_ALL_Order_Details_By_Products_Id(item.Id); table.Rows.Add(item.Id, item.Order_date, item.Customer.ID, item.Customer.First_Name, item.Customer.Last_Name, item.User_id, item.Total_paied); } dataGridView1.DataSource = table; dataGridView1.Columns[2].Visible = false; dataGridView1.Columns[5].Visible = false; //foreach (var item in list) //{ // table.Rows.Add(item.ID, item.First_Name, item.Last_Name, item.Tel, item.Email, item.Image); // count_ALL_items++; //} }
private void bills_Load(object sender, EventArgs e) { DataTable table = new DataTable(); table.Columns.Add("Id"); table.Columns.Add("first_Name"); table.Columns.Add("last_Name"); table.Columns.Add("tel"); table.Columns.Add("email"); table.Columns.Add("order_date"); table.Columns.Add("user_name"); DataTable details_table = new DataTable(); details_table.Columns.Add("quantity"); details_table.Columns.Add("total_price"); details_table.Columns.Add("discount"); details_table.Columns.Add("total_price_after_discount"); details_table.Columns.Add("label_product"); details_table.Columns.Add("price"); Order_Details_DATA order_details = new Order_Details_DATA(); order_details.Order = new Orders_DATA(); order_details.Order.Customer = new Customer_DATA(); order_details = Order_Details_BLL.Select_ALL_Order_Details().Last(); Customer_DATA customer = new Customer_DATA(); List <Orders_DATA> order = new List <Orders_DATA>(); order = Orders_BLL.Select_ALL_Orders(); foreach (var item in order) { if (order_details.Order.Id == item.Id) { order_details.Order.Customer = Customer_BLL.Select_Item_Customers(item.Customer); } } List <Order_Details_DATA> list_order_details = new List <Order_Details_DATA>(); list_order_details = Order_Details_BLL.Select_ALL_Order_Details(); list_order_details = Order_Details_BLL.Select_ALL_Order_Details().Where(x => x.Order.Id == order_details.Order.Id).ToList(); Users user = new Users(); List <Users> user_list = new List <Users>(); DataTable tables = DBL.get_DATA("Select_Users"); foreach (DataRow item in tables.Rows) { user_list.Add(new Users(item["Name"].ToString(), item["Password"].ToString(), Convert.ToInt16(item["ID_User"]))); } user.Id = order_details.Order.User_id; user = user_list.Single(x => x.Id == user.Id); table.Rows.Add( order_details.Order.Id, order_details.Order.Customer.First_Name, order_details.Order.Customer.Last_Name, order_details.Order.Customer.Tel, order_details.Order.Customer.Email, order_details.Order.Order_date, user.Name ); foreach (var item in list_order_details) { details_table.Rows.Add( item.Quantity, item.Total_price, item.Discount, item.Total_price_after_discount, item.Product.Label_product, item.Product.Price ); } CrystalReport_bill s = new CrystalReport_bill(); s.Subreports[0].SetDataSource(details_table); s.Subreports[0].AfterFormatPage += Bills_AfterFormatPage; s.SetDataSource(table); crystalReportViewer1.ReportSource = s; }
/* * USER NAME and Passwrod of both customer and administrator are saved after encryption. * One customer from file user name and password are * User name = ariz123 * Password = 12345 * * Administrator user name and password are * User name = Gull * Password = 12345 */ public void homeScreen() { int choice = 0; bool l_break = false; while (true) { Console.Clear(); WriteLine("\n\n\t\t\t\t ATM SOFTWARE\n\n"); WriteLine("\t\t\t Please Select the LogIn Type.\n\n\t\t\t Enter 1. For Administrator,\n\t\t\t 2. For Customer" + "\n\t\t\t 3. For exit."); try { Write("\t\t\t "); choice = System.Convert.ToInt32(ReadLine()); switch (choice) { case 1: string pre_login = ""; int login_count = 1; bool loop_break = false; while (true) { Console.Clear(); Write("\n\n\t\t\tEnter login: "******"\t\t\tEnter Pin code: "); Console.ForegroundColor = ConsoleColor.Green; string pin = pinInput(); Console.ForegroundColor = ConsoleColor.White; Administrator_BLL administrator_BLL = new Administrator_BLL(); if (administrator_BLL.loginAccessAdmin(u_id, pin) == true) { Administrator_View administrator_View1 = new Administrator_View(); administrator_View1.administratorMenu(); loop_break = true; } if (administrator_BLL.loginAccessAdmin(u_id, pin) == false) { WriteLine("\n\n\t\tWrong Credientials Press any Key to continue\t\t"); ReadKey(); Console.Clear(); } if (pre_login == u_id) { login_count++; } pre_login = u_id; if (loop_break == true) { break; } if (login_count == 3) { administrator_BLL.disableAccount(u_id); WriteLine("\n\nYou enter 3 time wrong password your account is disable Please contact to administrator. Press any key to continue"); ReadKey(); Console.Clear(); break; } } break; case 2: bool loop_b = false; int count = 1; string previousLogin = ""; while (true) { /*For disable account we suspose that customer always enter correct user name; * password is incorrect * Hence, we disable the account for this user name customer*/ Console.Clear(); WriteLine("\n\n\t\t\tCustomer Service.\n\n"); Write("\t\t\tEnter login: "******"\t\t\tEnter Pin code: "); Console.ForegroundColor = ConsoleColor.Green; string pin_code = pinInput(); Console.ForegroundColor = ConsoleColor.White; Customer_BLL customer_BLL = new Customer_BLL(); if (customer_BLL.loginAccess(login, pin_code) == true) { Customer_BO customer = customer_BLL.createCustomer(login, pin_code); Customer_View customer_View = new Customer_View(); customer_View.customerMenu(customer); loop_b = true; } else { WriteLine("\n\n\tWrong Credientials or account is disable Press any Key to continue\t\t\t"); ReadKey(); } if (previousLogin == login) { count++; } previousLogin = login; if (loop_b == true) { break; } if (count == 3) { customer_BLL.disableAccount(login); WriteLine("\n\nYou enter 3 time wrong password your account is disable Please contact to administrator. Press any key to continue"); ReadKey(); Console.Clear(); break; } } break; case 3: l_break = true; break; default: WriteLine("\n\tinvalid input Press any key to continue.\t"); ReadKey(); Console.Clear(); break; } } catch (System.FormatException) { WriteLine("Invalid input please enter integer value Press any key to continue"); ReadKey(); Console.Clear(); } catch (OverflowException) { WriteLine("\n\n\tPlease enter 1 or 2 or 3 Press any key to Continue"); ReadKey(); Console.Clear(); } catch (Exception e) { WriteLine(e.Message + " Invalid Input."); } if (l_break == true) { break; } } }