public BankAccountInformationView() { InitializeComponent(); BankAccountInformation data = new BankAccountInformation(); bankAccountInformation.ItemsSource = data.GetData(); DataContext = data; }
private void Remove_Click(object sender, RoutedEventArgs e) { RemoveDialogView handle = new RemoveDialogView(); if (handle.ShowDialog() == true) { using (SqlConnection con = new SqlConnection(@Connection.ConnectionString)) { if (handle.FirstInput != handle.SecondInput) { MessageBox.Show("Entry No. did not match.Try again.\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } Connection conn = new Connection(); conn.OpenConection(); int isLogin = 0; string query = "SELECT * From Stuff "; SqlDataReader reader = conn.DataReader(query); while (reader.Read()) { stuff_name = (string)reader["Stuff_Name"]; stuff_pass = (string)reader["Stuff_Password"]; if (stuff_name.Equals(Login.GlobalStuffName) && stuff_pass.Equals(handle.GetPassword)) { isLogin = 1; break; } } if (isLogin != 1) { MessageBox.Show("Wrong Password.Try again.\n", "Warning", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } using (SqlCommand command = new SqlCommand("DELETE FROM BankAccount WHERE BankAccount_Id = " + handle.FirstInput, con)) { con.Open(); command.ExecuteNonQuery(); con.Close(); MessageBox.Show("Successfully Deleted"); } Id = Convert.ToInt32(handle.FirstInput); dateTime = DateTime.Today; string table = "BankAccount"; string type = "Removed"; string color = "Red"; EntryLog entry = new EntryLog(); entry.Add_Entry(table, type, Id, dateTime, color); conn.CloseConnection(); BankAccountInformation data = new BankAccountInformation(); bankAccountInformation.ItemsSource = data.GetData(); DataContext = data; } } }
/// <summary> /// <see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/> /// </summary> /// <param name="bankAccountInformation"><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></param> /// <returns><see cref="Microsoft.Samples.NLayerApp.DistributedServices.MainModule.IMainModuleService"/></returns> public List <BankAccount> GetBankAccounts(BankAccountInformation bankAccountInformation) { //Resolve root dependency and perform operation IBankingManagementService bankingManagement = IoCFactory.Instance.CurrentContainer.Resolve <IBankingManagementService>(); List <BankAccount> bankAccounts = null; //perform work! bankAccounts = bankingManagement.FindBankAccounts(bankAccountInformation.BankAccountNumber, bankAccountInformation.CustomerName); return(bankAccounts); }
/// <summary> /// This method updates bank account information of particular bank /// </summary> /// <param name="bankAccountInformation">bankAccountInformation</param> /// <returns></returns> public bool UpdateBankAccountInformation(BankAccountInformation bankAccountInformation) { try { using (var unitOfWork = new EFUnitOfWork()) { var bankAccountRepo = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork); ObjectSet <BankAccountInformation> bankAccountInformationObjSet = ((CurrentDeskClientsEntities)bankAccountRepo.Repository.UnitOfWork.Context).BankAccountInformations; var selectedBankInformation = bankAccountInformationObjSet. Where(binfo => binfo.PK_BankAccountInformationID == bankAccountInformation.PK_BankAccountInformationID).SingleOrDefault(); if (selectedBankInformation != null) { selectedBankInformation.BankName = bankAccountInformation.BankName; selectedBankInformation.AccountNumber = bankAccountInformation.AccountNumber; selectedBankInformation.BicNumberOrSwiftCode = bankAccountInformation.BicNumberOrSwiftCode; selectedBankInformation.BankingAddress = bankAccountInformation.BankingAddress; selectedBankInformation.FK_ReceivingBankInformationID = bankAccountInformation.FK_ReceivingBankInformationID; selectedBankInformation.ReceivingBankInfo = bankAccountInformation.ReceivingBankInfo; selectedBankInformation.City = bankAccountInformation.City; selectedBankInformation.FK_CountryID = bankAccountInformation.FK_CountryID; selectedBankInformation.PostalCode = bankAccountInformation.PostalCode; } bankAccountRepo.Save(); return(true); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); throw; } }
/// <summary> /// This method adds new bank account for Live user /// </summary> /// <param name="userID">userID</param> /// <param name="bankAccountInformation">bankAccountInformation</param> /// <returns></returns> public bool AddNewLiveBankAccountInformation(int userID, BankAccountInformation bankAccountInformation) { try { using (var unitOfWork = new EFUnitOfWork()) { var bankRepo = new BankAccountInformationRepository(new EFRepository <BankAccountInformation>(), unitOfWork); var clientBO = new ClientBO(); var clientInformation = clientBO.GetClientInformation(userID); bankAccountInformation.FK_ClientID = clientInformation.PK_ClientID; bankRepo.Add(bankAccountInformation); bankRepo.Save(); return(true); } } catch (Exception ex) { CommonErrorLogger.CommonErrorLog(ex, System.Reflection.MethodBase.GetCurrentMethod().Name); throw; } }
public async Task UpdateTimeline(BankAccountInformation BAInfo) { await this.timelineTable.UpdateAsync(BAInfo); }
public async Task AddTimeline(BankAccountInformation BAInfo) { await this.timelineTable.InsertAsync(BAInfo); }
protected void Save_Click(object sender, RoutedEventArgs e) { if (CheckForError(Interest) || CheckForError(Deposit) || CheckForError(Withdraw) || CheckForError(ServiceCharge)) { MessageBox.Show("Error!Check Input Again"); return; } double remains = this.last_remains(); if ((string)Save.Content == "Save") { using (SqlConnection conn = new SqlConnection(@Connection.ConnectionString)) { SqlCommand CmdSql = new SqlCommand("INSERT INTO [BankAccount] (BankAccount_Date, BankAccount_Interest, BankAccount_Deposit, BankAccount_Withdraw, BankAccount_ServiceCharge,BankAccount_Remains) VALUES (@Date, @Interest, @Deposit, @Withdraw,@ServiceCharge, @Remains)", conn); conn.Open(); CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate); CmdSql.Parameters.AddWithValue("@Interest", Interest.Text); CmdSql.Parameters.AddWithValue("@Deposit", Deposit.Text); CmdSql.Parameters.AddWithValue("@Withdraw", ServiceCharge.Text); CmdSql.Parameters.AddWithValue("@ServiceCharge", Withdraw.Text); CmdSql.Parameters.AddWithValue("@Remains", remains + Convert.ToDouble(Deposit.Text) + Convert.ToDouble(Interest.Text) - Convert.ToDouble(Withdraw.Text) - Convert.ToDouble(ServiceCharge.Text)); CmdSql.ExecuteNonQuery(); conn.Close(); //Inserting value in Entry table Connection conn2 = new Connection(); string query = "SELECT TOP 1 * FROM BankAccount ORDER BY BankAccount_Id DESC"; conn2.OpenConection(); SqlDataReader reader = conn2.DataReader(query); while (reader.Read()) { Id = (int)reader["BankAccount_Id"]; dateTime = (DateTime)reader["BankAccount_Date"]; } conn2.CloseConnection(); string table = "Bank Account"; string type = "Inserted"; string color = "Green"; EntryLog entry = new EntryLog(); entry.Add_Entry(table, type, Id, dateTime, color); } } else { int temp_id = Id; Connection con = new Connection(); string query = "SELECT * FROM BankAccount Order by BankAccount_Id Asc"; con.OpenConection(); SqlDataReader reader = con.DataReader(query); while (reader.Read()) { string rid = reader["BankAccount_Id"].ToString(); int r_id = Convert.ToInt32(rid); string dep = reader["BankAccount_Deposit"].ToString(); double depint = Convert.ToDouble(dep); string with = reader["BankAccount_Withdraw"].ToString(); double withint = Convert.ToDouble(with); string intr = reader["BankAccount_Deposit"].ToString(); double intint = Convert.ToDouble(intr); string sc = reader["BankAccount_ServiceCharge"].ToString(); double scint = Convert.ToDouble(sc); //code (if block) for updating rest of the table if (temp_id < r_id) { Id = r_id; double remain = this.edited_total(); using (SqlConnection conn = new SqlConnection(@Connection.ConnectionString)) { SqlCommand CmdSql = new SqlCommand("UPDATE [BankAccount] SET BankAccount_Date = @Date , BankAccount_Deposit = @Deposit, BankAccount_Withdraw = @Withdraw, BankAccount_Interest = @Interest, BankAccount_Remains = @Remains WHERE BankAccount_Id=" + r_id, conn); conn.Open(); CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate); CmdSql.Parameters.AddWithValue("@Interest", intr); CmdSql.Parameters.AddWithValue("@Deposit", dep); CmdSql.Parameters.AddWithValue("@Withdraw", with); CmdSql.Parameters.AddWithValue("@ServiceCharge", sc); CmdSql.Parameters.AddWithValue("@Remains", remain + depint + intint - withint - scint); CmdSql.ExecuteNonQuery(); conn.Close(); } } //Code (else if block) for updating expected row else if (temp_id == r_id) { double remain = this.edited_total(); using (SqlConnection conn = new SqlConnection(@Connection.ConnectionString)) { SqlCommand CmdSql = new SqlCommand("UPDATE [BankAccount] SET BankAccount_Date = @Date , BankAccount_ServiceCharge = @ServiceCharge, BankAccount_Interest = @Interest, BankAccount_Deposit = @Deposit, BankAccount_Withdraw = @Withdraw, BankAccount_Remains = @Remains WHERE BankAccount_Id=" + EntryNo.Text, conn); conn.Open(); CmdSql.Parameters.AddWithValue("@Date", Date.SelectedDate); CmdSql.Parameters.AddWithValue("@Interest", Interest.Text); CmdSql.Parameters.AddWithValue("@Deposit", Deposit.Text); CmdSql.Parameters.AddWithValue("@Withdraw", Withdraw.Text); CmdSql.Parameters.AddWithValue("@ServiceCharge", ServiceCharge.Text); CmdSql.Parameters.AddWithValue("@Remains", remain + Convert.ToDouble(Deposit.Text) + Convert.ToDouble(Interest.Text) - Convert.ToDouble(Withdraw.Text) - Convert.ToDouble(ServiceCharge.Text)); CmdSql.ExecuteNonQuery(); conn.Close(); //Inserting value in Entry table Id = Convert.ToInt32(EntryNo.Text); dateTime = DateTime.Today; string table = "Bank Account"; string type = "Updated"; string color = "Blue"; EntryLog entry = new EntryLog(); entry.Add_Entry(table, type, Id, dateTime, color); } Save.Content = "Save"; } } con.CloseConnection(); } BankAccountInformation data = new BankAccountInformation(); bankAccountInformation.ItemsSource = data.GetData(); DataContext = data; }
/// <summary> /// POST: api/Messages /// Receive a message from a user and reply to it /// </summary> public async Task <HttpResponseMessage> Post([FromBody] Activity activity) { if (activity.Type == ActivityTypes.Message) { ConnectorClient connector = new ConnectorClient(new Uri(activity.ServiceUrl)); StateClient stateClient = activity.GetStateClient(); BotData userData = await stateClient.BotState.GetUserDataAsync(activity.ChannelId, activity.From.Id); LUISObj.RootObject LUISRoot; MapObj.RootObject mapRoot; var userMessage = activity.Text; string endOutput = ""; MobileServiceClient msclient = AzureManager.AzureManagerInstance.AzureClient; HttpClient client = new HttpClient(); string x = await client.GetStringAsync(new Uri(LUIS_URL + userMessage + "&timezoneOffset=12.0&verbose=true")); LUISRoot = JsonConvert.DeserializeObject <LUISObj.RootObject>(x); string intent = LUISRoot.topScoringIntent.intent; if (!userData.GetProperty <bool>(LOGGED_IN)) { BankAccountInformation information = await AzureManager.AzureManagerInstance.getAccountFromName(userMessage); if (information != null) { userData.SetProperty <BankAccountInformation>(PERSONAL_ACCOUNT, information); userData.SetProperty <bool>(LOGGED_IN, true); string name = userData.GetProperty <BankAccountInformation>(PERSONAL_ACCOUNT).Name; Activity reply = activity.CreateReply($"You have logged in successfully. Welcome {name}"); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); await connector.Conversations.ReplyToActivityAsync(reply); return(Request.CreateResponse(HttpStatusCode.OK)); } } if (intent == GREETING) { Activity greetingReply; if (userData.GetProperty <bool>(SENT_GREETING)) { greetingReply = activity.CreateReply($"Hello again"); } else { userData.SetProperty <bool>(SENT_GREETING, true); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); if (userData.GetProperty <bool>(LOGGED_IN)) { string name = userData.GetProperty <BankAccountInformation>(PERSONAL_ACCOUNT).Name; greetingReply = activity.CreateReply($"Hello {name}! What can I help you with?"); } else { greetingReply = activity.CreateReply($"Hello! What can I help you with?"); } } connector.Conversations.ReplyToActivity(greetingReply); return(Request.CreateResponse(HttpStatusCode.OK)); } else if (intent == FIND) { //use GPS co-ordinate system to find the nearest bank //use a card to display a map, and text saying the distance userData.SetProperty <bool>(SEARCHINGFORBANK, true); Activity reply = activity.CreateReply($"Please enter your current address"); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); await connector.Conversations.SendToConversationAsync(reply); return(Request.CreateResponse(HttpStatusCode.OK)); } else if (intent == INSULT) { Activity insultReply; if (userData.GetProperty <int>(INSULT_STRIKES) == 3) { //use a card or automatically call the helpline insultReply = activity.CreateReply($"Since you are having trouble, perhaps it would be better to call our helpline on 0800 83 83 83"); } else { userData.SetProperty <int>(INSULT_STRIKES, userData.GetProperty <int>(INSULT_STRIKES) + 1); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); insultReply = activity.CreateReply($"Please watch your language"); } await connector.Conversations.ReplyToActivityAsync(insultReply); return(Request.CreateResponse(HttpStatusCode.OK)); } else if (intent == MORE_INFORMATION) { Activity PaymentConversation = activity.CreateReply(); PaymentConversation.Recipient = activity.From; PaymentConversation.Type = "message"; PaymentConversation.Attachments = new List <Attachment>(); List <CardImage> cardImages = new List <CardImage>(); cardImages.Add(new CardImage(url: BANK_IMAGE_URL)); List <CardAction> cardButtons = new List <CardAction>(); CardAction travelBtn = new CardAction() { Value = "http://msa.ms", Type = "openUrl", Title = "Go to website" }; cardButtons.Add(travelBtn); ThumbnailCard confirmPaymentCard = new ThumbnailCard() { Title = "Website", Subtitle = "Visit our website for more information", Images = cardImages, Buttons = cardButtons }; Attachment confirmPaymentAttachment = confirmPaymentCard.ToAttachment(); PaymentConversation.Attachments.Add(confirmPaymentAttachment); await connector.Conversations.SendToConversationAsync(PaymentConversation); return(Request.CreateResponse(HttpStatusCode.OK)); } if (userMessage == CONFIRMED_PAYMENT) { Activity reply = activity.CreateReply("Processing your transaction..."); await connector.Conversations.ReplyToActivityAsync(reply); reply = activity.CreateReply("still processing..."); //update things and confirm payment string amount = userData.GetProperty <string>(POTENTIAL_PAYEE_AMOUNT); string payee = userData.GetProperty <string>(POTENTIAL_PAYEE); string payer = userData.GetProperty <BankAccountInformation>(PERSONAL_ACCOUNT).Name; BankAccountInformation personalAccount = userData.GetProperty <BankAccountInformation>(PERSONAL_ACCOUNT); BankAccountInformation temp = await AzureManager.AzureManagerInstance.getAccountFromName(payee); double actualAmount = Convert.ToDouble(amount); personalAccount.Money = personalAccount.Money - actualAmount; temp.Money = temp.Money + actualAmount; // personalAccount.password = "******"; await AzureManager.AzureManagerInstance.UpdateTimeline(personalAccount); await AzureManager.AzureManagerInstance.UpdateTimeline(temp); await connector.Conversations.ReplyToActivityAsync(reply); reply = activity.CreateReply($"payment of ${amount} to {payee} has been confirmed"); await connector.Conversations.ReplyToActivityAsync(reply); userData.SetProperty <string>(POTENTIAL_PAYEE, ""); userData.SetProperty <string>(POTENTIAL_PAYEE_AMOUNT, ""); BankAccountInformation payerAccount = await AzureManager.AzureManagerInstance.getAccountFromName(payer); userData.SetProperty <BankAccountInformation>(PERSONAL_ACCOUNT, payerAccount); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); return(Request.CreateResponse(HttpStatusCode.OK)); } else if (userMessage == CANCELLED_PAYMENT) { userData.SetProperty <string>(POTENTIAL_PAYEE, ""); userData.SetProperty <string>(POTENTIAL_PAYEE_AMOUNT, ""); Activity reply = activity.CreateReply($"Payment cancelled"); await connector.Conversations.ReplyToActivityAsync(reply); return(Request.CreateResponse(HttpStatusCode.OK)); } await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); if (userData.GetProperty <bool>(SEARCHINGFORBANK)) { string y = await client.GetStringAsync(new Uri(GOOGLE_URL + userMessage + "&destination=" + BANK_LOCATION + "&key=" + GOOGLE_API_KEY)); mapRoot = JsonConvert.DeserializeObject <MapObj.RootObject>(y); Activity PaymentConversation = activity.CreateReply(); PaymentConversation.Recipient = activity.From; PaymentConversation.Type = "message"; PaymentConversation.Attachments = new List <Attachment>(); List <CardImage> cardImages = new List <CardImage>(); //change to google maps image cardImages.Add(new CardImage(url: MAPS_IMAGE_URL)); List <CardAction> cardButtons = new List <CardAction>(); CardAction viewOnWebBtn = new CardAction() { Image = BANK_IMAGE_URL, Value = GOOGLE_MAPS_URL + userMessage + "/" + BANK_LOCATION, Type = "openUrl", Title = "View on Google Maps" }; cardButtons.Add(viewOnWebBtn); HeroCard confirmPaymentCard = new HeroCard() { Title = "Route", Subtitle = "Your nearest bank is at " + BANK_LOCATION + ". It is " + mapRoot.routes[0].legs[0].duration.text + " away.", Images = cardImages, Buttons = cardButtons }; Attachment confirmPaymentAttachment = confirmPaymentCard.ToAttachment(); PaymentConversation.Attachments.Add(confirmPaymentAttachment); await connector.Conversations.SendToConversationAsync(PaymentConversation); userData.SetProperty <bool>(SEARCHINGFORBANK, false); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); return(Request.CreateResponse(HttpStatusCode.OK)); } if (userData.GetProperty <bool>(LOGGED_IN)) { if (intent == PAYMENT) { var action = LUISRoot.topScoringIntent.actions[0]; //display a card with a confirm button, the amount, the payee if (action.parameters[0].value == null && action.parameters[1].value == null) { Activity testingReply = activity.CreateReply($"You require either a contact name or an account number to pay"); await connector.Conversations.ReplyToActivityAsync(testingReply); return(Request.CreateResponse(HttpStatusCode.OK)); } string luckyBugger; endOutput = null; if (action.parameters[0].value == null) { luckyBugger = action.parameters[1].value[0].entity; BankAccountInformation information = await AzureManager.AzureManagerInstance.getAccountFromNumber(luckyBugger); if (information == null) { endOutput = "The number " + luckyBugger + " does not exist in this database."; } } else { luckyBugger = action.parameters[0].value[0].entity; BankAccountInformation information = await AzureManager.AzureManagerInstance.getAccountFromName(luckyBugger); if (information == null) { endOutput = "The name " + luckyBugger + " does not exist in this database."; } } if (endOutput != null) { Activity reply = activity.CreateReply(endOutput); await connector.Conversations.ReplyToActivityAsync(reply); return(Request.CreateResponse(HttpStatusCode.OK)); } Activity PaymentConversation = activity.CreateReply(); PaymentConversation.Recipient = activity.From; PaymentConversation.Type = "message"; PaymentConversation.Attachments = new List <Attachment>(); List <CardImage> cardImages = new List <CardImage>(); cardImages.Add(new CardImage(url: BANK_IMAGE_URL)); List <CardAction> cardButtons = new List <CardAction>(); CardAction confirmButton = new CardAction() { Image = TICK_IMAGE_URL, Value = CONFIRMED_PAYMENT, Type = "postBack", Title = "confirm" }; cardButtons.Add(confirmButton); CardAction cancelBtn = new CardAction() { Image = CROSS_IMAGE_URL, Value = CANCELLED_PAYMENT, Type = "postBack", Title = "cancel" }; cardButtons.Add(cancelBtn); ThumbnailCard confirmPaymentCard = new ThumbnailCard() { Title = "Confirm Payment", Subtitle = "Please confirm you want to pay $" + action.parameters[2].value[0].entity + " to " + luckyBugger, Images = cardImages, Buttons = cardButtons }; userData.SetProperty <string>(POTENTIAL_PAYEE, luckyBugger); userData.SetProperty <string>(POTENTIAL_PAYEE_AMOUNT, action.parameters[2].value[0].entity); await stateClient.BotState.SetUserDataAsync(activity.ChannelId, activity.From.Id, userData); Attachment confirmPaymentAttachment = confirmPaymentCard.ToAttachment(); PaymentConversation.Attachments.Add(confirmPaymentAttachment); await connector.Conversations.SendToConversationAsync(PaymentConversation); return(Request.CreateResponse(HttpStatusCode.OK)); } else if (intent == APPOINTMENT) { Activity reply = activity.CreateReply($"Sorry I do not understand what you're saying"); await connector.Conversations.ReplyToActivityAsync(reply); return(Request.CreateResponse(HttpStatusCode.OK)); } else if (intent == CHECK_BALANCE) { double moneyAmount = userData.GetProperty <BankAccountInformation>(PERSONAL_ACCOUNT).Money; Activity bankStatement = activity.CreateReply("You have $" + moneyAmount + " in your bank account"); await connector.Conversations.ReplyToActivityAsync(bankStatement); } else if (intent == LOG_OUT) { await stateClient.BotState.DeleteStateForUserAsync(activity.ChannelId, activity.From.Id); Activity reply = activity.CreateReply($"log out successfull"); await connector.Conversations.ReplyToActivityAsync(reply); } else if (intent == NONE) { Activity reply = activity.CreateReply($"Sorry I do not understand what you're saying"); await connector.Conversations.ReplyToActivityAsync(reply); } } else { //not logged in Activity reply = activity.CreateReply("You are not logged in. Please enter your username to continue"); await connector.Conversations.ReplyToActivityAsync(reply); } // return our reply to the user // Activity reply = activity.CreateReply($"The intent is " + rootObject.topScoringIntent.intent); // await connector.Conversations.ReplyToActivityAsync(reply); } else { HandleSystemMessage(activity); } var response = Request.CreateResponse(HttpStatusCode.OK); return(response); }
public void Delete(BankAccountInformation entity) { Repository.Delete(entity); }
public void Add(BankAccountInformation entity) { Repository.Add(entity); }