public Transactions WithdrawCash(CustomerBO cbo, decimal amount) //first it creates transaction of withdraw type { //and then get the decrypted customers in a list and decrement Transactions ts = new Transactions { Type = "withdrawn", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount }; MainDAL dal = new MainDAL(); //amount from balance of that customer who is cbo. dal.CreateTrasaction(ts); List <CustomerBO> list = new List <CustomerBO>(); List <CustomerBO> newList = new List <CustomerBO>(); list = CustomerDecryption(); CustomerBO tempcbo = new CustomerBO(); foreach (CustomerBO u in list) { if (u.UserID == cbo.UserID) { u.Balance = u.Balance - amount; } tempcbo = u; tempcbo = CustomerEncryption(tempcbo); newList.Add(tempcbo); } dal.RestoreCustomerAccounts(newList); return(ts); }
public void DeleteRecord(CustomerBO cbo) //used to delete record. if the given record for deletion is the only { //only recors in the file then simply deletes it and write 'empty' to the file string filePath = Path.Combine(Environment.CurrentDirectory, "UserAccounts.csv"); //else simply makes a new list List <CustomerBO> listUser = new List <CustomerBO>(); //of customers and store all old data into the new list except the List <CustomerBO> newList = new List <CustomerBO>(); //record which we want to delete. and update the new list to file. listUser = CustomerDecryption(); int total = 0; MainDAL dal = new MainDAL(); foreach (CustomerBO b in listUser) { total++; } if (total == 1) { cbo.Login = "******"; newList.Add(cbo); dal.RestoreCustomerAccounts(newList); } else { CustomerBO currentcbo = new CustomerBO(); foreach (CustomerBO tmp in listUser) { if (tmp.AccountNo != cbo.AccountNo) { currentcbo = CustomerEncryption(tmp); newList.Add(currentcbo); } } dal.RestoreCustomerAccounts(newList); } }
public void CreateCustomerAccount(CustomerBO cbo) //used to create userr by just encrypting it and giving it to { //dal layer. CustomerEncryption(cbo); MainDAL dll = new MainDAL(); dll.CreateCustomerAccount(cbo); }
public Transactions DepositCash(CustomerBO cbo, decimal amount) //used to deposit a cash into a customer account { //firstly creates a transaction of deposit type and then add amount in the balance Transactions ts = new Transactions { Type = "deposited", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount }; MainDAL dal = new MainDAL(); //of cbo who is current user. dal.CreateTrasaction(ts); List <CustomerBO> old = CustomerDecryption(); List <CustomerBO> newList = new List <CustomerBO>(); CustomerBO tempBo = new CustomerBO(); foreach (CustomerBO u in old) { if (u.AccountNo == cbo.AccountNo) { u.Balance = u.Balance + amount; } tempBo = u; tempBo = CustomerEncryption(tempBo); newList.Add(tempBo); } dal.RestoreCustomerAccounts(newList); return(ts); }
public Transactions CashTransfer(CustomerBO cbo, decimal amount, int accNo) //used to transfer cash just like withdraw { //creates a transaction of transfer type and then decrease the balance from the Transactions ts = new Transactions { Type = "transfered", DT = DateTime.Now, UserID = cbo.UserID, Balance = amount }; MainDAL dal = new MainDAL(); //cbo's balance and increase in the balance of customer whose account number is dal.CreateTrasaction(ts); //accNo. List <CustomerBO> list = new List <CustomerBO>(); List <CustomerBO> newList = new List <CustomerBO>(); list = CustomerDecryption(); CustomerBO tempcbo = new CustomerBO(); foreach (CustomerBO u in list) { if (u.AccountNo == cbo.AccountNo) { u.Balance = u.Balance - amount; } if (u.AccountNo == accNo) { u.Balance = u.Balance + amount; } tempcbo = u; tempcbo = CustomerEncryption(tempcbo); newList.Add(tempcbo); } dal.RestoreCustomerAccounts(newList); return(ts); }
public AddCheckWindow(MainDAL dal) { this.dal = dal; InitializeComponent(); Init(); }
/// <summary> /// Initialized a new instance of the AddBookPageViewModel class. /// </summary> public AddProductPageViewModel(MainDAL dal) { //Creates the commands bound to from the view. AddProductCommand = new Command(AddProductCommand_Execute, CanExecute); DeleteProductCommand = new Command(DeleteProductCommand_Execute, CanExecute); DAL = dal; }
/// <summary> /// Initializes a new instance of the MakeListPageViewModel class. /// </summary> public MakeListPageViewModel(MainDAL dal) { //Creates the commands bound to from the view. SortByName_Command = new Command(SortByName_Command_Execute, CanListBeSorted); SortByShop_Command = new Command(SortByShop_Command_Execute, CanListBeSorted); DAL = dal; }
public TypeSetPage(MainDAL dal) { this.dal = dal; InitializeComponent(); Query(); }
public CheckConfigWindow(MainDAL dal) { this.dal = dal; InitializeComponent(); Init(); }
public bool isLoginUseridExist(string login, string userID) //to check whether any customer with given login or user id { //exist in the file or not. if login is null then check it for MainDAL dal = new MainDAL(); //user idd and vice versa for the validtion purposes. bool isFileExist = dal.isFileExist("UserAccounts.csv"); if (!isFileExist) { return(false); } List <CustomerBO> list = new List <CustomerBO>(); list = CustomerDecryption(); if (login != null) { foreach (CustomerBO cbo in list) { if (cbo.Login == login) { return(true); } } } else if (userID != null) { foreach (CustomerBO cbo in list) { if (cbo.UserID == userID) { return(true); } } } return(false); }
public HistoryWindow(MainDAL dal) { this.dal = dal; InitializeComponent(); Init(); }
private void Init() { dal = new MainDAL(config); var typeList = dal.GetAllAssemblyType(); if (typeList.Any()) { StartType(typeList.FirstOrDefault()); } }
/// <summary> /// Initializes a new instance of the MainPageViewModel class. /// </summary> /// <param name="addBookPage"></param> /// <param name="makeListPage"></param> public MainPageViewModel(AddProductPage addProductPage, MakeListPage makeListPage, MainDAL dal) { this.addProductPage = addProductPage; this.makeListPage = makeListPage; DAL = dal; //Creates the commands bound to from the view. ToolbarItem_ADD_Command = new Command(ToolbarItem_ADD_Command_Execute); ToolbarItem_FILL_Command = new Command(ToolbarItem_FILL_Command_Execute); ClearBtn_Command = new Command(ClearBtn_Command_Execute, ClearBtn_Command_CanExecute); DeleteModeBtn_Command = new Command(DeleteModeBtn_Command_Execute, DeleteModeBtn_Command_CanExecute); }
public List <Transactions> ReportByDate(DateTime start, DateTime end, string userID) //reads the transaction { //list and save those in new list whome dates lies between the given range. MainDAL dal = new MainDAL(); List <Transactions> old = new List <Transactions>(); List <Transactions> newData = new List <Transactions>(); old = dal.ReadTransactions(); foreach (Transactions t in old) { if (t.DT >= start && t.DT <= end && t.UserID == userID) { newData.Add(t); } } return(newData); }
private void BTN_DialogSubjectAdd_Click(object sender, EventArgs e) { bool pass = true; string msg = ""; int i = 1; if (!ValidateInput.IsValid(TXT_DialogSubjectName)) { pass = false; msg += i + ". Subject Name must not be blank\n"; i++; } if (!pass) { msg += "\nRequired fields must be valid."; MessageBox.Show(null, msg, "Required", MessageBoxButtons.OK, MessageBoxIcon.Warning); DialogResult = DialogResult.None; return; } // If validation successful IMainDAL cmd = new MainDAL(); if (editUpdate) { Subject subject = new Subject() { Id = int.Parse(LBL_DialogSubjectId.Text), Name = TXT_DialogSubjectName.Text }; if (cmd.UpdateSubject(subject)) { mainForm.GetView("Subjects"); } } else { Subject subject = new Subject() { Name = TXT_DialogSubjectName.Text }; if (cmd.AddSubject(subject)) { mainForm.GetView("Subjects"); } } }
public List <AdminBO> AdminDecryption() //used for the decryption of whole admin file. just read admin in admin list and conver { //it in decrypted form by just calling techninque method for both login and pin. List <AdminBO> adm = new List <AdminBO>(); List <AdminBO> decrypted = new List <AdminBO>(); MainDAL dal = new MainDAL(); adm = dal.ReadAdmin(); foreach (var itr in adm) { string s1 = itr.Login; string s2 = itr.pin; Technique(ref s1); Technique(ref s2); AdminBO tmp = new AdminBO { Login = s1, pin = s2 }; decrypted.Add(tmp); } return(decrypted); }
public List <CustomerBO> CustomerDecryption() //used for the decryption of complete customer file. just read customer in customer list and conver { //it in decrypted form by just calling techninque method for both login and pin. List <CustomerBO> adm = new List <CustomerBO>(); List <CustomerBO> decrypted = new List <CustomerBO>(); MainDAL dal = new MainDAL(); adm = dal.ReadCustomer(); foreach (CustomerBO itr in adm) { string s1 = itr.Login; string s2 = itr.Pin; Technique(ref s1); Technique(ref s2); CustomerBO tmp = new CustomerBO(); tmp = itr; tmp.Login = s1; tmp.Pin = s2; decrypted.Add(tmp); } return(decrypted); }
public bool IsAbleToWithdraw(ref decimal amt, CustomerBO cbo, decimal amount) //checks whether the customer is able { //to withdraw cash by checking the withdrawal limit of customer string path = Path.Combine(Environment.CurrentDirectory, "Transactions.csv"); //whether it reaches 20000 or not. bool isExist = File.Exists(path); //amount is the given amount to withdraw and and ref amt is the amount ramins if (!isExist) //for the withdraw for today. { return(true); } else { MainDAL dal = new MainDAL(); List <Transactions> listTrns = dal.ReadTransactions(); amt = CheckTotalWithdrawal(listTrns, cbo); if (amt + amount <= 20000) { return(true); } } return(false); }
public bool isAdminIDExist(string login) //simply checks whether any admin exist with the given adminID in order { //to validate admin. MainDAL dal = new MainDAL(); bool isFileExist = dal.isFileExist("Administrators.csv"); if (!isFileExist) { return(false); } List <AdminBO> list = new List <AdminBO>(); list = AdminDecryption(); foreach (AdminBO cbo in list) { if (cbo.Login == login) { return(true); } } return(false); }
public void UpdateRecords(List <string> list, int acc) //used to update the record with the contents given in the list { //this method just get the decrypted data and transfer it to the new List <CustomerBO> old = new List <CustomerBO>(); //list of customers and update the customer with the account List <CustomerBO> NewData = new List <CustomerBO>(); //number given by sending that customer to the UpdateSingle old = CustomerDecryption(); //Record. CustomerBO cbo = new CustomerBO(); foreach (CustomerBO tmp in old) { cbo = tmp; if (tmp.AccountNo == acc) { cbo = UpdateSingleRecord(tmp, list); } cbo = CustomerEncryption(cbo); NewData.Add(cbo); } MainDAL dal = new MainDAL(); dal.RestoreCustomerAccounts(NewData); }
public void MakeAccountDisable(string login) //only make the customer account disable against the given login id. { List <CustomerBO> old = new List <CustomerBO>(); List <CustomerBO> NewData = new List <CustomerBO>(); old = CustomerDecryption(); CustomerBO cbo = new CustomerBO(); foreach (CustomerBO tmp in old) { cbo = tmp; if (tmp.Login == login) { cbo.Status = "disable"; } cbo = CustomerEncryption(cbo); NewData.Add(cbo); } MainDAL dal = new MainDAL(); dal.RestoreCustomerAccounts(NewData); }
public int LastAccountNumber() //To get last account number. if file does not exist then simply return 0 else { //or if file contains 'empty' string again returns 0 and else return account number MainDAL dal = new MainDAL(); //of last account created. bool isTrue = dal.isFileExist("UserAccounts.csv"); if (!isTrue) { return(0); } else { List <string> listString = dal.LastAccNo(); string last = listString.Last(); if (last[last.Length - 1] == 'y') { return(0); } List <CustomerBO> tempCbo = CustomerDecryption(); CustomerBO cbo = tempCbo.Last(); return(cbo.AccountNo); } }
public bool Login(string _user, string _pass) { MainDAL mainDal = new MainDAL(); return(mainDal.Login(_user, _pass)); }
/// <summary> /// 查询最新上市书籍 /// </summary> /// <returns></returns> public static SqlDataReader SelectNewBook() { return(MainDAL.SelectNewBook()); }
/// <summary> /// 查询BLID /// </summary> /// <returns></returns> public static SqlDataReader LoadMsg() { return(MainDAL.LoadMsg());; }
public bool IsLoginMatched(string loginCheck, string pinCheck, ref int wrongs, ref int who, ref bool exist) { //used to validate login, pin credietials at the time of login into the system MainDAL dal = new MainDAL(); //for both admins and customers. if its correct then returns true else check bool isMatched = false; //checks for the 3 wrong inputs and if there are three then returns a signal of 3 string exName = loginCheck.ToLower(); //wrong inputs. if (exName[0] == 'a' && exName[1] == 'd' && exName[2] == 'm' && exName[3] == 'i' && exName[4] == 'n') { who = -1; //who==-1 means user is administrator. } else { who = 0; //who==0 means user is customer. } List <AdminBO> admList = new List <AdminBO>(); List <CustomerBO> usrList = new List <CustomerBO>(); if (who == -1) //admin login validation. { bool isExist = dal.isFileExist("AdministratorData.csv"); //if file does not exist often on the first time access if (!isExist) //to the system then it will automatically geneated the 3 dummy admins as there are no admins { //bydefault. AdminBO abo1 = new AdminBO { Login = "******", pin = "12345" }; abo1 = AdminEncryption(abo1); dal.SaveAdmin(abo1); AdminBO abo2 = new AdminBO { Login = "******", pin = "12345" }; abo2 = AdminEncryption(abo2); dal.SaveAdmin(abo2); AdminBO abo3 = new AdminBO { Login = "******", pin = "12345" }; abo3 = AdminEncryption(abo3); dal.SaveAdmin(abo3); } admList = AdminDecryption(); foreach (AdminBO itr in admList) { if (itr.Login == exName && itr.pin == pinCheck) { isMatched = true; break; } } } else if (who == 0) //customer login validation { bool isExist = dal.isFileExist("UserAccounts.csv"); if (!isExist) { exist = false; return(false); } usrList = CustomerDecryption(); foreach (CustomerBO itr in usrList) { if (itr.Login == loginCheck && itr.Pin == pinCheck) { isMatched = true; break; } } } if (isMatched == false) { wrongs++; } return(isMatched); }
public List <AdminBO> ReadAdmin() //just to read admins from the mainDal readAdmin function { MainDAL dal = new MainDAL(); return(dal.ReadAdmin()); }
public List <CustomerBO> ReadCustomer() //just to read customers from the mainDal readCustomer function { MainDAL dal = new MainDAL(); return(dal.ReadCustomer()); }
private void BTN_DialogSemesterAdd_Click(object sender, EventArgs e) { bool pass = true; string msg = ""; int i = 1; if (!ValidateInput.IsValid(CMB_DialogSemesterYear)) { pass = false; msg += i + ". A year must be selected\n"; i++; } if (!ValidateInput.IsValid(CMB_DialogSemesterSemester)) { pass = false; msg += i + ". A semester must be selected\n"; i++; } if (!ValidateInput.IsValid(DTP_DialogSemesterFirstTermStart)) { pass = false; msg += i + ". First term start date must be selected\n"; i++; } if (!ValidateInput.IsValid(DTP_DialogSemesterFirstTermEnd)) { pass = false; msg += i + ". First term end date must be selected\n"; i++; } if (ValidateInput.IsValid(DTP_DialogSemesterFirstTermStart) && ValidateInput.IsValid(DTP_DialogSemesterFirstTermEnd) && !ValidateInput.IsValid(DTP_DialogSemesterFirstTermStart, DTP_DialogSemesterFirstTermEnd)) { pass = false; msg += i + ". First term end date must be after start date\n"; i++; } if (!ValidateInput.IsValid(DTP_DialogSemesterSecondTermStart)) { pass = false; msg += i + ". Second term start date must be selected\n"; i++; } if (ValidateInput.IsValid(DTP_DialogSemesterFirstTermEnd) && ValidateInput.IsValid(DTP_DialogSemesterSecondTermStart) && !ValidateInput.IsValid(DTP_DialogSemesterFirstTermEnd, DTP_DialogSemesterSecondTermStart)) { pass = false; msg += i + ". Second term start date must be after first term\n"; i++; } if (!ValidateInput.IsValid(DTP_DialogSemesterSecondTermEnd)) { pass = false; msg += i + ". Second term end date must be selected\n"; i++; } if (ValidateInput.IsValid(DTP_DialogSemesterSecondTermStart) && ValidateInput.IsValid(DTP_DialogSemesterSecondTermEnd) && !ValidateInput.IsValid(DTP_DialogSemesterSecondTermStart, DTP_DialogSemesterSecondTermEnd)) { pass = false; msg += i + ". Second term end date must be after start date\n"; i++; } if (!pass) { msg += "\nRequired fields must be valid."; MessageBox.Show(null, msg, "Required", MessageBoxButtons.OK, MessageBoxIcon.Warning); DialogResult = DialogResult.None; return; } Semester semester = new Semester() { Year = new DateTime((int)CMB_DialogSemesterYear.SelectedItem, 1, 1), SecondSemester = ((int)CMB_DialogSemesterSemester.SelectedItem).Equals(2), FirstTermBegin = DTP_DialogSemesterFirstTermStart.Value.Date, FirstTermEnd = DTP_DialogSemesterFirstTermEnd.Value.Date, SecondTermBegin = DTP_DialogSemesterSecondTermStart.Value.Date, SecondTermEnd = DTP_DialogSemesterSecondTermEnd.Value.Date }; IMainDAL cmd = new MainDAL(); // If validation successful if (editUpdate) { if (cmd.UpdateSemester(semester)) { mainForm.GetView("Semesters"); } } else { if (cmd.AddSemester(semester)) { mainForm.GetView("Semesters"); } } }