private void DeleteUser() { lblAmendError.Text = ""; bool success = false; string username = tbUsername.Text; try { using (QCAstServiceClient client = new QCAstServiceClient()) { success = client.DeleteUser(int.Parse(tbUserId.Text)); } if (success) { ClearTextAndListBoxes(); lblSuccess.Text = string.Format("User {0} has been successfully deleted.", username); } else { lblAmendError.Text = "Cannot delete the user at this time. Please try again later."; } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "User Management DeleteUser", ex.ToString()); lblAmendError.Text = "The website encountered an error processing your request. The webmaster has been notified and will be attending to it shortly."; } }
protected void btnLogin_Click(object sender, ImageClickEventArgs e) { string result = ""; string idUser = ""; lblError.Text = ""; try { using (QCAstServiceClient serviceRef = new QCAstServiceClient()) { List <KeyValuePair <string, string> > authenticationResult = serviceRef.AuthenticateUser(txtUserName.Text, txtPassword.Text); result = authenticationResult.Where(p => p.Key == "Result").FirstOrDefault().Value; if (result != "Success") { lblError.Text = result; } else { idUser = authenticationResult.Where(p => p.Key == "IdUser").FirstOrDefault().Value; Session.Add("IdUser", idUser); FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false); } } } catch (Exception ex) { NotifyWebmasterOfError("QCAstBilling", "Login", ex.ToString()); lblError.Text = "Website encountered an error."; } }
protected void DdlClientsSelectedIndexChanged(object sender, EventArgs e) { lblError.Text = ""; if (ddlClients.SelectedIndex == 0) { ClearListBoxes(); } else { try { using (var client = new QCAstServiceClient()) { ddlClientInvoiceHistory.Items.Clear(); ddlClientInvoiceHistory.DataSource = client.GetInvoicesForClient(int.Parse(ddlClients.SelectedValue)); ddlClientInvoiceHistory.DataBind(); ddlClientInvoiceHistory.Items.Insert(0, new ListItem("-- Current Invoice --", "0")); } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Billing ddlSelectedIndex_Changed", ex.ToString()); lblError.Text = "The website encountered a problem retrieving the list of invoices for this client. The webmaster has been notified and will be attending to the problem shortly."; } } }
private void SaveUser() { bool success = false; string username = tbUsername.Text.Trim(); try { using (QCAstServiceClient client = new QCAstServiceClient()) { success = client.SaveUser(ddlProfiles.SelectedIndex, username, tbPassword.Text.Trim(), ddlClient.SelectedValue != "" ? int.Parse(ddlClient.SelectedValue) : (int?)null); } if (success) { ClearTextAndListBoxes(); lblSuccess.Text = string.Format("User '{0}' has been successfully added.", username); } else { lblAmendError.Text = string.Format("The website encountered and error saving User '{0}'", tbUsername.Text); } } catch (Exception ex) { NotifyWebmasterOfError("Ast Billing", "Usermanagement", ex.ToString()); lblAmendError.Text = "The website encountered a problem. The webmaster has been notified and will be attending to the problem."; } }
private void RunSummaryByOrigin() { var clientId = int.Parse(ddlClient.SelectedValue); if (ddlClient.SelectedIndex == 0) { Response.Write("<script type='text/javascript'>alert('Please select a client!');</script>"); } else { try { using (var client = new QCAstServiceClient()) { var clientName = client.GetClientFromId(clientId).ClientName; rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsInvoiceSummary", client.GetSummaryByOrigin(clientId))); rptViewer.ProcessingMode = ProcessingMode.Local; rptViewer.LocalReport.ReportPath = @"Reports\StatementSummaryBySrc.rdlc"; var clientDescription = new ReportParameter("ClientDescription", clientName); rptViewer.LocalReport.SetParameters(new[] { clientDescription }); rptViewer.LocalReport.EnableHyperlinks = true; rptViewer.LocalReport.Refresh(); rptViewer.LocalReport.DataSources.Clear(); rptViewer.Reset(); } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Report RunTopTwentyCallsByDuration", ex.ToString()); } } }
private void RunUndefinedDestinations() { lblError.Text = ""; try { using(var client = new QCAstServiceClient()) { rptViewer.LocalReport.DataSources.Clear(); rptViewer.Reset(); var rdInvDetail = new ReportDataSource("dsUndefinedDest", client.GetUndefinedDestinations().AsEnumerable()); rptViewer.LocalReport.DataSources.Add(rdInvDetail); rptViewer.ProcessingMode = ProcessingMode.Local; rptViewer.LocalReport.ReportPath = @"Reports\UndefinedDestinations2.rdlc"; rptViewer.LocalReport.Refresh(); } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Reports", ex.ToString()); lblError.Text = "The website encountered a problem running the report. The webmaster has been notified and will be attending to the problem."; } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { try { using (QCAstServiceClient client = new QCAstServiceClient()) { int idUser = int.Parse(Session["IdUser"].ToString()); User user = client.GetUserFromId(idUser); if (user.IdProfile != 4 & user.IdProfile != 3) { Response.Redirect("ErrorPage.aspx?Error=NotAuthorised", false); } else { ddlPrefContactMethod.DataSource = client.GetAllContactMethods(); ddlPrefContactMethod.DataBind(); lbSearchedClients.DataSource = client.GetAllClients("All", ""); lbSearchedClients.DataBind(); ddlPrefContactMethod.Items.Insert(0, new ListItem("Please select..", "0")); trButtons.Visible = false; ibEditClient.Enabled = false; ibDeleteClient.Enabled = false; } } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Client Management Page Load", ex.ToString()); Response.Redirect("ErrorPage.aspx?Error=GeneralError", true); } } }
protected void DeleteClient() { lblAmendError.Text = ""; bool success = false; string clientName = tbClientDesc.Text; try { using (QCAstServiceClient client = new QCAstServiceClient()) { success = client.DeleteClient(int.Parse(tbClientId.Text)); } if (success) { ClearListAndTextboxes(); lblSuccess.Text = string.Format("Client {0} has been successfully deleted.", clientName); } else { lblAmendError.Text = "Cannot delete the client at this time. Please try again later."; } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Client Management", ex.ToString()); lblAmendError.Text = string.Format("The website experienced a problem deleting client {0}. The webmaster has been notified and will be attending to the problem.", clientName); } }
protected void lbSearchedUsers_SelectedIndexChanged(object sender, EventArgs e) { int id = int.Parse(((ListBox)sender).SelectedValue); try { using (QCAstServiceClient client = new QCAstServiceClient()) { User user = client.GetUserFromId(id); tbUserId.Text = user.IdUser.ToString(); tbUsername.Text = user.Username; tbPassword.Text = user.Password; ddlProfiles.SelectedIndex = user.IdProfile; if (user.IdClient != null) { ddlClient.SelectedIndex = ddlClient.Items.IndexOf(ddlClient.Items.FindByValue(user.IdClient.Value.ToString())); } else { ddlClient.SelectedIndex = 0; } } ibEditUser.Enabled = true; ibDeleteUser.Enabled = true; } catch (Exception ex) { NotifyWebmasterOfError("Billing", "User Management SearchSelectedIndexChanged", ex.ToString()); } }
private void EditUser() { string username = tbUsername.Text; lblAmendError.Text = ""; bool success = false; try { using (QCAstServiceClient client = new QCAstServiceClient()) { success = client.EditUser(int.Parse(tbUserId.Text), ddlProfiles.SelectedIndex, username, tbPassword.Text, ddlClient.SelectedValue != "" ? int.Parse(ddlClient.SelectedValue) : (int?)null); } if (success) { ClearTextAndListBoxes(); lblSuccess.Text = string.Format("User {0} has been successfully amended", username); } else { lblAmendError.Text = "The user could not be amended at this time"; } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "User Management EditUser", ex.ToString()); lblAmendError.Text = "The website encountered a problem updating the User details. The webmaster has been notified and will be attending to it shortly"; } }
private void RunInvoiceHistory() { lblError.Text = ""; try { var idClient = int.Parse(ddlClients.SelectedValue); var idInvoice = int.Parse(ddlClientInvoiceHistory.SelectedValue); using (var client = new QCAstServiceClient()) { rptViewer.LocalReport.DataSources.Clear(); rptViewer.Reset(); var invoiceDate = client.GetInvoiceDate(idInvoice); var invoiceDetails = client.GetInvoicedDetailsForClient(idClient, idInvoice); var invoiceSummaries = client.GetInvoicedSummaryForClient(idClient, idInvoice); if (invoiceDetails.Count == 0) { lblError.Text = string.Format("No data available for Client {0}", ddlClients.SelectedItem.Text); } else { var rdInvDetail = new ReportDataSource("dsInvoiceDetail", invoiceDetails.AsEnumerable()); var rdInvSummary = new ReportDataSource("dsInvoiceSummary", invoiceSummaries.AsEnumerable()); rptViewer.LocalReport.DataSources.Add(rdInvDetail); rptViewer.LocalReport.DataSources.Add(rdInvSummary); rptViewer.ProcessingMode = ProcessingMode.Local; rptViewer.LocalReport.ReportPath = @"Reports\InvoiceDetail.rdlc"; var startDate = invoiceDetails.OrderByDescending(p => p.CallDate).LastOrDefault().CallDate.ToString(); var endDate = invoiceDetails.OrderByDescending(p => p.CallDate).FirstOrDefault().CallDate.ToString(); var clientDescription = new ReportParameter("ClientDescription", ddlClients.SelectedItem.ToString()); var reportDescription = new ReportParameter("ReportDescription", "From : " + startDate + Environment.NewLine + "To : " + endDate); var totalDuration = new ReportParameter("TotalDuration", client.GetTotalDuration(idClient, invoiceDate)); rptViewer.LocalReport.SetParameters(new ReportParameter[] { clientDescription, reportDescription, totalDuration }); rptViewer.LocalReport.Refresh(); btnCreateInvoice.Visible = false; } } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "AdminBilling RunInvoiceHistory", ex.ToString()); lblError.Text = "The website encountered a problem retrieving the invoice detail for this report. The webmaster has been notified and will be attending to the problem."; } }
protected void Page_Load(object sender, EventArgs e) { if (Session["IdUser"] == null) { FormsAuthentication.RedirectToLoginPage(); } else { if (!IsPostBack) { try { HideDivs(); idUser = int.Parse(Session["IdUser"].ToString()); int idProfile = 0; using (QCAstServiceClient serviceRef = new QCAstServiceClient()) { idProfile = serviceRef.GetUserFromId(idUser).IdProfile; switch (idProfile) { case 1: divUserMenu.Visible = true; break; case 2: divDatamanagerMenu.Visible = true; break; case 3: divClientManagerMenu.Visible = true; break; case 4: divAdminMenu.Visible = true; break; case 5: divClientMenu.Visible = true; break; default: break; } } } catch (Exception ex) { NotifyWebmasterOfError("QCAstBilling", "Site.Master", ex.ToString()); Response.Redirect("ErrorPage.aspx?Error=GeneralError", true); } } } }
private void RunCurrentStatement() { lblError.Text = ""; try { DateTime periodEndDate; var idClient = int.Parse(ddlClient.SelectedValue); if (DateTime.TryParseExact(Request.Form[txtEndDate.UniqueID], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out periodEndDate)) { using (var client = new QCAstServiceClient()) { rptViewer.LocalReport.DataSources.Clear(); rptViewer.Reset(); var rdInvDetail = new ReportDataSource("dsInvoiceDetail", client.GetInvoiceDetail); var rdInvSummary = new ReportDataSource("dsInvoiceSummary", dsSummary.Tables[0]); rptViewer.LocalReport.DataSources.Add(rdInvDetail); rptViewer.LocalReport.DataSources.Add(rdInvSummary); rptViewer.ProcessingMode = ProcessingMode.Local; rptViewer.LocalReport.ReportPath = @"Reports\InvoiceDetail.rdlc"; // Get the date range to show on the report var startDate = (from dta in dsDetail.Tables[0].AsEnumerable() orderby dta.Field<DateTime>("CallDate") ascending select (dta.Field<DateTime>("CallDate"))).FirstOrDefault(); var endDate = (from dta in dsDetail.Tables[0].AsEnumerable() orderby dta.Field<DateTime>("CallDate") ascending select (dta.Field<DateTime>("CallDate"))).LastOrDefault(); // Configure report params ReportParameter ClientDescription = null; if (Session["profilename"].ToString() == "Client") { ClientDescription = new ReportParameter("ClientDescription", Session["ClientDesc"].ToString()); } else { ClientDescription = new Microsoft.Reporting.WebForms.ReportParameter("ClientDescription", this.lstClient.SelectedItem.ToString()); } Microsoft.Reporting.WebForms.ReportParameter ReportDescription = new Microsoft.Reporting.WebForms.ReportParameter("ReportDescription", "From : " + startDate + Environment.NewLine + "To : " + endDate); this.rptViewer.LocalReport.SetParameters(new Microsoft.Reporting.WebForms.ReportParameter[] { ClientDescription, ReportDescription }); this.rptViewer.LocalReport.Refresh(); } } } else { Response.Write("<script type='text/javascript'>alert('Please select a valid date');</script>"); } }
protected void lbSearchedClients_SelectedIndexChanged(object sender, EventArgs e) { int id = int.Parse(((ListBox)sender).SelectedValue); ClearListAndTextboxes(); try { using (QCAstServiceClient client = new QCAstServiceClient()) { Client fetchedClient = client.GetClientFromId(id); tbClientId.Text = fetchedClient.IdClient.ToString(); tbClientDesc.Text = fetchedClient.ClientName; tbRangeFrom.Text = fetchedClient.RangeFrom != null?fetchedClient.RangeFrom.Value.ToString() : ""; tbRangeTo.Text = fetchedClient.RangeTo != null?fetchedClient.RangeTo.Value.ToString() : ""; tbClientCode.Text = fetchedClient.ClientCode; tbAccountingCode.Text = fetchedClient.AccountingCode; tbCellular.Text = fetchedClient.CellularNumber ?? ""; tbEmail.Text = fetchedClient.Email ?? ""; ddlPrefContactMethod.SelectedIndex = ddlPrefContactMethod.Items.IndexOf( ddlPrefContactMethod.Items.FindByValue(fetchedClient.ContactMethod.ToString())); tbMaxDuration.Text = fetchedClient.MaxCallDuration != null ? fetchedClient.MaxCallDuration.Value.ToString() : ""; tbMaxIntDuration.Text = fetchedClient.MaxIntCallDuration != null ? fetchedClient.MaxIntCallDuration.Value.ToString() : ""; string maxIntPrice = fetchedClient.MaxIntCallPrice != null ? fetchedClient.MaxIntCallPrice.Value.ToString() : ""; tbMaxIntPrice.Text = maxIntPrice != "" ? maxIntPrice.Remove(maxIntPrice.Length - 4, 3) : ""; string maxPrice = fetchedClient.MaxCallPrice != null ? fetchedClient.MaxCallPrice.Value.ToString() : ""; tbMaxPrice.Text = maxPrice != "" ? maxPrice.Remove(maxPrice.Length - 4, 3) : ""; } ibEditClient.Enabled = true; ibDeleteClient.Enabled = true; } catch (Exception ex) { NotifyWebmasterOfError("Billing", "User Management SearchSelectedIndexChanged", ex.ToString()); } }
protected void EditClient() { lblAmendError.Text = ""; bool success = false; string clientName = tbClientDesc.Text; try { Client editClient = new Client { CellularNumber = tbCellular.Text != "" ? tbCellular.Text : null, AccountingCode = tbAccountingCode.Text, ClientCode = tbClientCode.Text, ClientName = tbClientDesc.Text, ContactMethod = ddlPrefContactMethod.SelectedIndex == 0 ? 4 : int.Parse(ddlPrefContactMethod.SelectedValue), IdClient = int.Parse(tbClientId.Text), MaxCallDuration = tbMaxDuration.Text != "" ? int.Parse(tbMaxDuration.Text) : (int?)null, MaxCallPrice = tbMaxPrice.Text != "" ? decimal.Parse(tbMaxPrice.Text) : (decimal?)null, MaxIntCallDuration = tbMaxIntDuration.Text != "" ? int.Parse(tbMaxIntDuration.Text) : (int?)null, MaxIntCallPrice = tbMaxIntPrice.Text != "" ? decimal.Parse(tbMaxIntPrice.Text) : (decimal?)null, RangeFrom = tbRangeFrom.Text != "" ? int.Parse(tbRangeFrom.Text) : (int?)null, RangeTo = tbRangeTo.Text != "" ? int.Parse(tbRangeTo.Text) : (int?)null, Email = tbEmail.Text != "" ? tbEmail.Text : null }; using (QCAstServiceClient client = new QCAstServiceClient()) { success = client.EditClient(editClient); } if (success) { ClearListAndTextboxes(); lblSuccess.Text = string.Format("Client {0} has been successfully amended.", clientName); } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Client Management EditClient", ex.ToString()); lblAmendError.Text = string.Format("The website experienced a problem editing client {0}. The webmaster has been notified and will be attending to the problem.", clientName); } }
protected void ibBtnSubmit_Click(object sender, ImageClickEventArgs e) { lblAmendError.Text = ""; bool usernameTaken = false; try { if (tbUsername.Text == "" | tbPassword.Text == "" | ddlProfiles.SelectedIndex == 0) { lblAmendError.Text = "Please provide values for the Username, Password and Profile fields"; } else { if (ddlProfiles.SelectedIndex != 4 & ddlClient.SelectedIndex == 0) { lblAmendError.Text = "User not Admin. Please provide values for the Client field"; } else { using (QCAstServiceClient client = new QCAstServiceClient()) { usernameTaken = client.CheckIfUserExists(tbUsername.Text.Trim()); } if (usernameTaken) { lblAmendError.Text = "Username taken, please enter new username"; } else { SaveUser(); } } } } catch (Exception ex) { NotifyWebmasterOfError("Ast Billing", "Usermanagement", ex.ToString()); lblAmendError.Text = "The website encountered a problem. The webmaster has been notified and will be attending to the problem."; } }
protected void BtnCreateInvoiceClick(object sender, EventArgs e) { lblError.Text = ""; lblSuccess.Text = ""; DateTime endDate; var idUser = int.Parse(Session["IdUser"].ToString()); var idClient = int.Parse(ddlClients.SelectedValue); if (DateTime.TryParseExact(Request.Form[txtEndDate.UniqueID], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out endDate)) { try { using (var client = new QCAstServiceClient()) { bool success = client.CreateInvoice(idClient, endDate, idUser); if (success) { lblSuccess.Text = "Invoice has been successfully captured in the database."; ClearListBoxes(); } else { lblError.Text = "The website encountered a problem creating an invoice. The webmaster has been notified and will be attending to the problem."; } } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "AdminBilling btnCreateInvoice", ex.ToString()); lblError.Text = "The website encountered a problem creating an invoice. The webmaster has been notified and will be attending to the problem."; } } else { Response.Write("<script type='text/javascript'>alert('Please enter a valid date');</script>"); } }
private void RunTopTwentyCallsByCost() { DateTime periodEndDate; DateTime periodStartDate; var clientId = int.Parse(ddlClient.SelectedValue); if (!DateTime.TryParseExact(Request.Form[txtEndDate.UniqueID], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out periodEndDate) | !DateTime.TryParseExact(Request.Form[txtEndDate.UniqueID], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out periodStartDate)) { Response.Write("<script type='text/javascript'>alert('Please select valid dates in the Start Date and End Date fields!');</script>"); } else if (ddlClient.SelectedIndex == 0) { Response.Write("<script type='text/javascript'>alert('Please select a client!');</script>"); } else { try { using (var client = new QCAstServiceClient()) { rptViewer.LocalReport.DataSources.Clear(); rptViewer.Reset(); var topTwenty = client.GetTop20ByCost(clientId, periodStartDate, periodEndDate); rptViewer.LocalReport.DataSources.Add(new ReportDataSource("dsInvoiceDetail", topTwenty.AsEnumerable())); rptViewer.ProcessingMode = ProcessingMode.Local; rptViewer.LocalReport.ReportPath = @"Reports\Top20ByCost.rdlc"; var startDate = topTwenty.OrderByDescending(p => p.CallDate).LastOrDefault().CallDate; var endDate = topTwenty.OrderByDescending(p => p.CallDate).FirstOrDefault().CallDate; var clientDescription = new ReportParameter("ClientDescription", ddlClient.SelectedValue); var reportDescription = new ReportParameter("ReportDescription", "From : " + startDate + Environment.NewLine + "To : " + endDate); rptViewer.LocalReport.SetParameters(new ReportParameter[] { clientDescription, reportDescription }); rptViewer.LocalReport.Refresh(); } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Report RunTopTwentyCallsByDuration", ex.ToString()); } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { if (Session["IdUser"] == null) { FormsAuthentication.RedirectToLoginPage(); } else { var idUser = int.Parse(Session["IdUser"].ToString()); try { using (var serviceClient = new QCAstServiceClient()) { var user = serviceClient.GetUserFromId(idUser); if (user.IdProfile != 4) { Response.Redirect("ErrorPage.aspx?Error=NotAuthorised"); } else { ddlReport.DataSource = serviceClient.GetAllReports(); ddlReport.DataBind(); ddlReport.Items.Insert(0, new ListItem("Please select..", "0")); ddlClient.DataSource = serviceClient.GetAllClients("All", ""); ddlClient.DataBind(); ddlClient.Items.Insert(0, new ListItem("Please select..", "0")); ClearListAndTextBoxes(); } } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Reports PageLoad", ex.ToString()); } } } }
protected void Page_Load(object sender, EventArgs e) { if (Session["IdUser"] == null) { FormsAuthentication.RedirectToLoginPage(); } else { if (!IsPostBack) { try { using (QCAstServiceClient client = new QCAstServiceClient()) { int idUser = int.Parse(Session["IdUser"].ToString()); User user = client.GetUserFromId(idUser); if (user.IdClient == null) { Response.Redirect("AdminBilling.aspx"); } else { int idClient = user.IdClient.Value; ddlClientInvoiceHistory.Items.Clear(); ddlClientInvoiceHistory.DataSource = client.GetInvoicesForClient(idClient); ddlClientInvoiceHistory.DataBind(); ddlClientInvoiceHistory.Items.Insert(0, new ListItem("Please select..", "0")); Session.Add("IdClient", idClient); } } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "ClientBilling Page_Load", ex.ToString()); Response.Redirect("ErrorPage.aspx?Error=GeneralError"); } } } }
protected void btnSearch_Click(object sender, ImageClickEventArgs e) { string searchTerm = tbSearch.Text; ClearListAndTextboxes(); if (searchTerm == "" & rblSearchFormat.SelectedValue != "All") { lblSearchError.Text = "Please enter a search term"; } else { try { using (QCAstServiceClient client = new QCAstServiceClient()) { lblSearchError.Text = ""; List <Client> clients = client.GetAllClients(rblSearchFormat.SelectedValue, searchTerm); if (clients == null) { lblSearchError.Text = "No results found"; lblSearchError.Visible = true; } else { lbSearchedClients.DataSource = clients; lbSearchedClients.DataBind(); } } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Client Management Search", ex.ToString()); lblSearchError.Text = "Error experienced"; } } }
protected void ibBtnSubmit_Click(object sender, ImageClickEventArgs e) { lblAmendError.Text = ""; bool clientExists = false; try { if (tbClientDesc.Text == "" | tbClientCode.Text == "" | tbAccountingCode.Text == "") { lblAmendError.Text = "Please provide values for the 'Client Name', 'Client Code' and 'Accounting Code' fields."; } else { using (QCAstServiceClient client = new QCAstServiceClient()) { clientExists = client.CheckIfClientExists(tbAccountingCode.Text.Trim()); } if (clientExists) { lblAmendError.Text = "Client already exists in the database"; } else { AddClient(); } } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Client Management ibBtnSubmit_Click", ex.ToString()); lblAmendError.Text = "The website encountered a problem adding the client. The webmaster has been notified and will be attending to it shortly"; } }
private void AddClient() { bool success = false; string clientName = tbClientDesc.Text; if (tbClientDesc.Text == "" | tbClientCode.Text == "" | tbAccountingCode.Text == "") { lblAmendError.Text = "Please provide values for the Client Name, Client Code and Accounting Code fields"; } else { try { Client newClient = new Client { CellularNumber = tbCellular.Text != "" ? tbCellular.Text : null, AccountingCode = tbAccountingCode.Text, ClientCode = tbClientCode.Text.Trim(), ClientName = tbClientDesc.Text.Trim(), ContactMethod = ddlPrefContactMethod.SelectedIndex == 0 ? 4 : int.Parse(ddlPrefContactMethod.SelectedValue), RangeFrom = tbRangeFrom.Text != "" ? int.Parse(tbRangeFrom.Text) : (int?)null, RangeTo = tbRangeTo.Text != "" ? int.Parse(tbRangeTo.Text) : (int?)null, Email = tbEmail.Text != "" ? tbEmail.Text : null, MaxCallDuration = tbMaxDuration.Text != "" ? int.Parse(tbMaxDuration.Text) : (int?)null, MaxCallPrice = tbMaxPrice.Text != "" ? decimal.Parse(tbMaxPrice.Text) : (decimal?)null, MaxIntCallDuration = tbMaxIntDuration.Text != "" ? int.Parse(tbMaxIntDuration.Text) : (int?)null, MaxIntCallPrice = tbMaxIntPrice.Text != "" ? decimal.Parse(tbMaxIntPrice.Text) : (decimal?)null, LastUpdated = DateTime.Now }; using (QCAstServiceClient client = new QCAstServiceClient()) { success = client.AddClient(newClient); } if (success) { ClearListAndTextboxes(); lblSuccess.Text = string.Format("Client '{0}' has been successfully added.", clientName); } else { lblAmendError.Text = string.Format("The website encountered and error saving Client '{0}'", clientName); } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Client Management AddClient", ex.ToString()); lblAmendError.Text = "The website encountered a problem saving the Client. The webmaster has been notified and will be attending to it shortly."; } } }
private void RunCurrentInvoice() { lblError.Text = ""; try { DateTime periodEndDate; var idClient = int.Parse(ddlClients.SelectedValue); if (DateTime.TryParseExact(Request.Form[txtEndDate.UniqueID], "yyyy-MM-dd", CultureInfo.InvariantCulture, DateTimeStyles.None, out periodEndDate)) { using (var client = new QCAstServiceClient()) { rptViewer.LocalReport.DataSources.Clear(); rptViewer.Reset(); List <InvoiceDetail> invoiceDetails = client.GetUninvoicedDetailsForClient(idClient, periodEndDate); List <InvoiceSummary> invoiceSummaries = client.GetUninvoicedSummaryForClient(idClient, periodEndDate); if (invoiceDetails.Count == 0) { lblError.Text = string.Format("No data available for Client {0}", ddlClients.SelectedItem.Text); } else { var rdInvDetail = new ReportDataSource("dsInvoiceDetail", invoiceDetails.AsEnumerable()); var rdInvSummary = new ReportDataSource("dsInvoiceSummary", invoiceSummaries.AsEnumerable()); rptViewer.LocalReport.DataSources.Add(rdInvDetail); rptViewer.LocalReport.DataSources.Add(rdInvSummary); rptViewer.ProcessingMode = ProcessingMode.Local; rptViewer.LocalReport.ReportPath = @"Reports\InvoiceDetail.rdlc"; var startDate = invoiceDetails.OrderByDescending(p => p.CallDate).LastOrDefault().CallDate.ToString(); var endDate = invoiceDetails.OrderByDescending(p => p.CallDate).FirstOrDefault().CallDate.ToString(); var clientDescription = new ReportParameter("ClientDescription", ddlClients.SelectedItem.ToString()); var reportDescription = new ReportParameter("ReportDescription", "From : " + startDate + Environment.NewLine + "To : " + endDate); var totalDuration = new ReportParameter("TotalDuration", client.GetTotalDuration(idClient, periodEndDate)); rptViewer.LocalReport.SetParameters(new ReportParameter[] { clientDescription, reportDescription, totalDuration }); rptViewer.LocalReport.Refresh(); btnCreateInvoice.Visible = true; } } } else { Response.Write("<script type='text/javascript'>alert('Please select a valid date');</script>"); } } catch (Exception ex) { NotifyWebmasterOfError("Billing", "Billing RunCurrentInvoice", ex.ToString()); lblError.Text = "The website encountered a problem retrieving the invoice detail for this report. The webmaster has been notified and will be attending to the problem."; } }