16,004,458 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View .NET questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by MIDCOPC (Top 15 by date)
MIDCOPC
8-Nov-23 7:56am
View
RainHat, thank you for the reply. I got it working with the code below. Not sure if this is the correct way but it is working.
public void invoicePostingReportPrintReportButton_Click(object sender, EventArgs e)
{
if (invoicemainresults == null)
{
MessageBox.Show("You must create a report before you can print it");
invoicePostingReportStartDateTimePicker.Focus();
return;
}
// Get list of printers from Personnel table
var getPrinters = GlobalConfig.PersonnelTable.GetByPersonCodeForPrinting(_userId);
if (getPrinters != null && getPrinters.PrinterNameReports != null)
{
printTo = getPrinters.PrinterPathReports;
// Create a PrintDocument object
PrintDocument printDocument1 = new PrintDocument();
// Set up print settings
printDocument1.PrinterSettings.PrinterName = printTo;
printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Letter", 850, 1100);
// Set up event handler for printing
printDocument1.PrintPage += new PrintPageEventHandler(printDocument1_PrintPage);
// Calculate the number of items per page
int itemsPerPage = 30; // Adjust this value as needed
// Calculate the total number of pages
int totalPages = (int)Math.Ceiling((double)invoicemainresults.Count / itemsPerPage);
// Print each page
for (int currentPage = 1; currentPage <= totalPages; currentPage++)
{
// Set the starting and ending index for the current page
int startIndex = (currentPage - 1) * itemsPerPage;
int endIndex = Math.Min(startIndex + itemsPerPage - 1, invoicemainresults.Count - 1);
// Clear the variables
this._sProNumber = string.Empty;
this._sLoadNumber = string.Empty;
this._sShipmentNumber = string.Empty;
this._sBillDate = string.Empty;
this._sInvoiceCreatedDate = string.Empty;
this._sInvoicePostedDate = string.Empty;
this._sTotalCharges = string.Empty;
this._sTotalPayments = string.Empty;
this._sBalanceDue = string.Empty;
// Populate the variables with data for the current page
for (int i = startIndex; i <= endIndex; i++)
{
var result = invoicemainresults[i];
_sProNumber += result.ProNumber + Environment.NewLine + Environment.NewLine;
_sLoadNumber += result.LoadNumber + Environment.NewLine + Environment.NewLine;
_sShipmentNumber += result.ShipmentNumber + Environment.NewLine + Environment.NewLine;
_sBillDate += result.BillDate.ToShortDateString() + Environment.NewLine + Environment.NewLine;
_sInvoiceCreatedDate += result.InvoiceCreatedDate.ToShortDateString() + Environment.NewLine + Environment.NewLine;
_sInvoicePostedDate += result.InvoicePostedDate.ToShortDateString() + Environment.NewLine + Environment.NewLine;
_sTotalCharges += result.TotalCharges + Environment.NewLine + Environment.NewLine;
_sTotalPayments += result.TotalPayments + Environment.NewLine + Environment.NewLine;
_sBalanceDue += result.BalanceDue + Environment.NewLine + Environment.NewLine;
}
// Print the current page
printDocument1.Print();
}
}
}
MIDCOPC
21-Jul-23 9:32am
View
We set custom format on the DTP to " ". In our environment, we schedule appointments. If the DPT shows a date, say today's date, we can't trust our users to change the date of the appointment, so we have it blank when the form.
MIDCOPC
18-Jul-23 7:34am
View
This solution will work as long as there is an existing date in the DTP. When I open the winform, the date is blank.
MIDCOPC
8-Jul-21 19:53pm
View
Thank you. After reading this I was able to get what I needed.
MIDCOPC
7-Jul-21 17:14pm
View
I don't know where to start. I have the file list going to the console but I need save it in memory then search the table to see if any file names match records in the table.
MIDCOPC
1-Oct-20 7:20am
View
Form B:
public void DisplayRecord(string loadNumber)
{
var loadresult = GlobalConfig.Load_MainTable.GetByLoadNumber(loadNumber);
if (loadresult != null)
{
if (loadresult.InUseBy == "0") // Record not in use
{
// Hold the record for current user
GlobalConfig.Load_MainTable.TakeOwnership(loadresult.LoadMainId, UserId);
// Store the LoadMainId of the current record
CurrentRecordId = loadresult.LoadMainId;
// Populate form
_firstPickUpAccountCode = loadresult.FirstPickUpAccountCode;
_lastDeliveryAccountCode = loadresult.LastDeliveryAccountCode;
loadNumberValue.Text = loadresult.LoadNumber;
shipmentNumberValue.Text = loadresult.ShipmentNumber;
loadStatusValue.Text = loadresult.LoadStatus;
shipperAccountCodeValue.Text = loadresult.ShipperAccountCode;
shipperName1Value.Text = loadresult.ShipperName1;
_shipperName2Value = loadresult.ShipperName2;
_shipperPhoneValue = loadresult.ShipperPhone;
_shipperAddressValue = loadresult.ShipperAddress;
_shipperCityValue = loadresult.ShipperCity;
_shipperStateValue = loadresult.ShipperState;
_shipperZipCodeValue = loadresult.ShipperZipCode;
shipperEmailsValue.Text = loadresult.ShipperEmails;
{
if (loadresult.Send214)
send214Checkbox.Checked = true;
}
bCOValue.Text = loadresult.BCO;
// Get lists based on BCO
LoadAssignmentLists();
LoadOtherSRCList();
// Continue populating
billToAccountCodeValue.Text = loadresult.BillToAccountCode;
billtoName1Value.Text = loadresult.BillToName1;
_billToName2Value = loadresult.BillToName2;
_billToPhoneValue = loadresult.BillToPhone;
_billToAddressValue = loadresult.BillToAddress;
_billToCityValue = loadresult.BillToCity;
_billToStateValue = loadresult.BillToState;
_billToZipCodeValue = loadresult.BillToZipCode;
{
if (loadresult.Send210)
_billToSend210 = 1;
}
totalWeightValue.Text = loadresult.TotalWeight;
totalVolumeValue.Text = loadresult.TotalVolume;
totalQuantityValue.Text = loadresult.TotalQuantity;
totalPickUpsValue.Text = loadresult.TotalPickUps;
totalDeliveriesValue.Text = loadresult.TotalDeliveries;
_stops = Int32.Parse(totalDeliveriesValue.Text) + Int32.Parse(totalPickUpsValue.Text);
totalMilesValue.Text = loadresult.TotalMiles;
trailerValue.Text = loadresult.Trailer;
trailerNumberValue.Text = loadresult.Trailer;
sealNumberValue.Text = loadresult.SealNumber;
// Change format of DTP based on null/MinDate or not
if (loadresult.TrailerDroppedDate.Equals(DateTime.MinValue))
{
trailerDroppedDateValue.CustomFormat = " ";
}
else
{
trailerDroppedDateValue.Cu
MIDCOPC
1-Oct-20 7:19am
View
Tables are the same. One is current data other is history data.
I am trying not to duplicate the code if possible
Form A:
using SpeadIMLibrary;
using SpeadIMLibrary.DataAccess.Models;
using SpeadIMUI.FormTools;
using SpeadIMUI.Interfaces;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace SpeadIMUI.Forms
{
public partial class AccessorialsMenuForm : Form
{
// Stores the instance of the parent form (LoginForm)
private Form _parent;
// Stores the userID of the currently loggid in user
private readonly string _userId;
public AccessorialsMenuForm(Form parent, string userId)
{
InitializeComponent();
_parent = parent;
_userId = userId;
}
private void accessorialsMenuGOButton_Click(object sender, EventArgs e)
{
if (createModifyReviewAccessorialsRadioButton.Checked)
{
var mainresult = GlobalConfig.Load_MainTable.GetByLoadNumber(loadSearchBoxValue.Text);
//TODO fix locking form
if (mainresult != null)//load is in load_mail
{
if (createModifyReviewAccessorialsRadioButton.Checked && (!string.IsNullOrWhiteSpace(loadSearchBoxValue.Text)))
{
// Pass LoadNumber to LoadProcessingForm
LoadProcessingForm frm = new LoadProcessingForm(this, _userId, loadSearchBoxValue.Text);
if (frm.IsDisposed == false)
{
frm.Show();
}
loadSearchBoxValue.Text = "";
createModifyReviewAccessorialsRadioButton.Checked = true;
return;
}
}
else //test to see if in history
{
var historyresult = GlobalConfig.History_Load_MainTable.GetByLoadNumber(loadSearchBoxValue.Text);
if (historyresult != null) //load is in history_load_main
{
// Pass LoadNumber to LoadProcessingForm
LoadProcessingForm frm = new LoadProcessingForm(this, _userId, loadSearchBoxValue.Text);
if (frm.IsDisposed == false)
{
frm.Show();
}
loadSearchBoxValue.Text = "";
createModifyReviewAccessorialsRadioButton.Checked = true;
return;
}
}
//TODO: Use textbox to locate load then pass info to form
//LoadFinancialSummaryForm frm = new LoadFinancialSummaryForm(this, _userId, add additional parameters here );
//if (_parent is SpeadIMStartForm mainForm)
//{
// mainForm.openForms.Add(frm);
//}
//frm.Show();
createModifyReviewAccessorialsRadioButton.Checked = false;
return;
}
else if (accessorialsReportsRadioButton.Checked)
{
// TODO: Change ApplyPaymentForm to a reports menu form
//ApplyPaymentForm frm = new ApplyPaymentForm(this, _userId);
//openForms.Add(frm);
//frm.Show();
accessorialsReportsRadioButton.Checked = false;
return;
}
else
{
MessageBox.Show($"A Radio Button must be selected.");
return;
}
}
}
}
Form B: just code to populate form:
public void DisplayRecord(string loadNumber)
{
var loadresult = GlobalConfig.Load_MainTable.GetByLoadNumber(loadNumber);
if (loadresult != null)
MIDCOPC
28-Sep-20 19:17pm
View
Yes for you it was that simple. I am new to this. Thank you for helping!
MIDCOPC
20-Sep-19 7:10am
View
MySQL is installed and working.
MIDCOPC
22-May-19 15:53pm
View
Thank Rick. I am already connected to the database.
MIDCOPC
22-May-19 15:34pm
View
I don't know where start to create the search options. I have the combobox working.
// Create the Search List
private void LoadSearchList()
{
List<string> SearchList = new List<string>
{
"Code",
"Name",
"City"
};
AccountSearchListValue.DataSource = SearchList;
MIDCOPC
22-May-19 14:47pm
View
Data is in an MySQL database.
MIDCOPC
24-Sep-18 17:31pm
View
Update: I am using Dapper and MySQL. I have been over the code and fixed all of the spelling errors. In MySQL I can see the connection to the database but still get the error when I click the update button.
MIDCOPC
14-Sep-18 11:28am
View
@Richard, I don't think it is a custom extension. I am new at this. I will look and see if I can add to the MySqlConnection class. Thank you
MIDCOPC
11-Sep-18 17:52pm
View
I have fixed the spelling errors. The windows form will come up, I can enter data and click update. Then I get the error. System.Collections.Generic.KeyNotFoundException {"The given key was not present in the dictionary."}
Show More