mirror of
https://github.com/stokebob/BealeEngineering.git
synced 2026-03-19 06:37:15 +00:00
Added ability to delete a sales invoice
This commit is contained in:
@@ -192,7 +192,7 @@
|
|||||||
// xeroInvoiceToolStripMenuItem
|
// xeroInvoiceToolStripMenuItem
|
||||||
//
|
//
|
||||||
this.xeroInvoiceToolStripMenuItem.Name = "xeroInvoiceToolStripMenuItem";
|
this.xeroInvoiceToolStripMenuItem.Name = "xeroInvoiceToolStripMenuItem";
|
||||||
this.xeroInvoiceToolStripMenuItem.Size = new System.Drawing.Size(180, 22);
|
this.xeroInvoiceToolStripMenuItem.Size = new System.Drawing.Size(139, 22);
|
||||||
this.xeroInvoiceToolStripMenuItem.Text = "Xero Invoice";
|
this.xeroInvoiceToolStripMenuItem.Text = "Xero Invoice";
|
||||||
this.xeroInvoiceToolStripMenuItem.Click += new System.EventHandler(this.xeroInvoiceToolStripMenuItem_Click);
|
this.xeroInvoiceToolStripMenuItem.Click += new System.EventHandler(this.xeroInvoiceToolStripMenuItem_Click);
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -20,16 +20,56 @@ namespace BealeEngineering.Accounts
|
|||||||
private bool isDirtyClientPo = true;
|
private bool isDirtyClientPo = true;
|
||||||
private bool isDirtyProjectWork = true;
|
private bool isDirtyProjectWork = true;
|
||||||
|
|
||||||
Core.Logic.Sale.SaleInvoiceAssign assignInvoice;
|
Core.Logic.Sale.AssignInvoice assignInvoice;
|
||||||
|
|
||||||
public frmMain()
|
public frmMain()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
sqlConnectionString = ConfigurationManager.ConnectionStrings["BealeEngSQLDb"].ToString();
|
sqlConnectionString = ConfigurationManager.ConnectionStrings["BealeEngSQLDb"].ToString();
|
||||||
assignInvoice = new Core.Logic.Sale.SaleInvoiceAssign(sqlConnectionString);
|
assignInvoice = new Core.Logic.Sale.AssignInvoice(sqlConnectionString);
|
||||||
UpdateInvoiceImportText();
|
UpdateInvoiceImportText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool IsDirtyInvoiceAllocation
|
||||||
|
{
|
||||||
|
get { return isDirtyInvoiceAllocation; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
isDirtyInvoiceAllocation = value;
|
||||||
|
IsDirtyRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDirtySaleInvoice
|
||||||
|
{
|
||||||
|
get { return isDirtySaleInvoice; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
isDirtySaleInvoice = value;
|
||||||
|
IsDirtyRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDirtyClientPo
|
||||||
|
{
|
||||||
|
get { return isDirtyClientPo; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
isDirtyClientPo = value;
|
||||||
|
IsDirtyRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsDirtyProjectWork
|
||||||
|
{
|
||||||
|
get { return isDirtyProjectWork; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
isDirtyProjectWork = value;
|
||||||
|
IsDirtyRefresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public List<string> TableData { get; set; }
|
public List<string> TableData { get; set; }
|
||||||
|
|
||||||
private void Form1_Load(object sender, EventArgs e)
|
private void Form1_Load(object sender, EventArgs e)
|
||||||
@@ -39,32 +79,35 @@ namespace BealeEngineering.Accounts
|
|||||||
|
|
||||||
private void TabSetAllIsDirty()
|
private void TabSetAllIsDirty()
|
||||||
{
|
{
|
||||||
isDirtyInvoiceAllocation = true;
|
IsDirtyInvoiceAllocation = true;
|
||||||
isDirtySaleInvoice = true;
|
IsDirtySaleInvoice = true;
|
||||||
isDirtyClientPo = true;
|
IsDirtyClientPo = true;
|
||||||
isDirtyProjectWork = true;
|
IsDirtyProjectWork = true;
|
||||||
|
}
|
||||||
|
|
||||||
tabControl1_SelectedIndexChanged(null, null);
|
public void IsDirtyRefresh()
|
||||||
|
{
|
||||||
|
if (tabControl1.SelectedTab == tabControl1.TabPages["tabClientPoAllocation"] && IsDirtyInvoiceAllocation)
|
||||||
|
{
|
||||||
|
RefreshTabInvoiceAllocation();
|
||||||
|
}
|
||||||
|
else if (tabControl1.SelectedTab == tabControl1.TabPages["tabSaleInvoice"] && IsDirtySaleInvoice)
|
||||||
|
{
|
||||||
|
btnRefreshSaleInvoice_Click(null, null);
|
||||||
|
}
|
||||||
|
else if (tabControl1.SelectedTab == tabControl1.TabPages["tabClientPo"] && IsDirtyClientPo)
|
||||||
|
{
|
||||||
|
btnRefreshClientPo_Click(null, null);
|
||||||
|
}
|
||||||
|
else if (tabControl1.SelectedTab == tabControl1.TabPages["tabProjectWork"] && IsDirtyProjectWork)
|
||||||
|
{
|
||||||
|
btnRefreshProjectWork_Click(null, null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (tabControl1.SelectedTab == tabControl1.TabPages["tabClientPoAllocation"] && isDirtyInvoiceAllocation)
|
IsDirtyRefresh();
|
||||||
{
|
|
||||||
RefreshTabInvoiceAllocation();
|
|
||||||
}
|
|
||||||
else if (tabControl1.SelectedTab == tabControl1.TabPages["tabSaleInvoice"] && isDirtySaleInvoice)
|
|
||||||
{
|
|
||||||
btnRefreshSaleInvoice_Click(null, null);
|
|
||||||
}
|
|
||||||
else if (tabControl1.SelectedTab == tabControl1.TabPages["tabClientPo"] && isDirtyClientPo)
|
|
||||||
{
|
|
||||||
btnRefreshClientPo_Click(null, null);
|
|
||||||
}
|
|
||||||
else if (tabControl1.SelectedTab == tabControl1.TabPages["tabProjectWork"] && isDirtyProjectWork)
|
|
||||||
{
|
|
||||||
btnRefreshProjectWork_Click(null, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshTabInvoiceAllocation()
|
private void RefreshTabInvoiceAllocation()
|
||||||
@@ -72,7 +115,7 @@ namespace BealeEngineering.Accounts
|
|||||||
btnRefreshInvAllocation_Click(null, null);
|
btnRefreshInvAllocation_Click(null, null);
|
||||||
UpdateInvoiceCombo();
|
UpdateInvoiceCombo();
|
||||||
UpdateInvoiceImportText();
|
UpdateInvoiceImportText();
|
||||||
isDirtyInvoiceAllocation = false;
|
IsDirtyInvoiceAllocation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cmbInvoicePick_SelectedIndexChanged(object sender, EventArgs e)
|
private void cmbInvoicePick_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
@@ -96,7 +139,7 @@ namespace BealeEngineering.Accounts
|
|||||||
|
|
||||||
private void UpdateInvoiceCombo()
|
private void UpdateInvoiceCombo()
|
||||||
{
|
{
|
||||||
var idList = new Core.Data.Database.Client.ReadSaleInvoiceAllocation(sqlConnectionString).GetUnallocatedInvoice();
|
var idList = new Core.Data.Database.Sale.ReadSaleInvoiceAllocation(sqlConnectionString).GetUnallocatedInvoice();
|
||||||
var readInvoice = new Core.Data.Database.Sale.ReadInvoiceHeader(sqlConnectionString);
|
var readInvoice = new Core.Data.Database.Sale.ReadInvoiceHeader(sqlConnectionString);
|
||||||
readInvoice.InvoiceNumber = idList;
|
readInvoice.InvoiceNumber = idList;
|
||||||
|
|
||||||
@@ -117,8 +160,9 @@ namespace BealeEngineering.Accounts
|
|||||||
var currentSaleInvoice = new Core.Data.Database.Sale.ReadInvoice(sqlConnectionString).BySaleInvoiceId(invoiceId);
|
var currentSaleInvoice = new Core.Data.Database.Sale.ReadInvoice(sqlConnectionString).BySaleInvoiceId(invoiceId);
|
||||||
|
|
||||||
|
|
||||||
var frmInvoice = new frmSaleInvoice(currentSaleInvoice);
|
var frmInvoice = new frmSaleInvoice(sqlConnectionString, currentSaleInvoice, this);
|
||||||
frmInvoice.ShowDialog();
|
frmInvoice.ShowDialog();
|
||||||
|
IsDirtyRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnRefreshInvAllocation_Click(object sender, EventArgs e)
|
private void btnRefreshInvAllocation_Click(object sender, EventArgs e)
|
||||||
@@ -338,7 +382,7 @@ namespace BealeEngineering.Accounts
|
|||||||
invoiceData.OrderByDescending(x => x.SaleInvoiceNumber
|
invoiceData.OrderByDescending(x => x.SaleInvoiceNumber
|
||||||
.Substring(x.SaleInvoiceNumber.IndexOf("#") + 1, x.SaleInvoiceNumber.Length - x.SaleInvoiceNumber.IndexOf("#") - 1));
|
.Substring(x.SaleInvoiceNumber.IndexOf("#") + 1, x.SaleInvoiceNumber.Length - x.SaleInvoiceNumber.IndexOf("#") - 1));
|
||||||
|
|
||||||
isDirtySaleInvoice = false;
|
IsDirtySaleInvoice = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnAssign_Click(object sender, EventArgs e)
|
private void btnAssign_Click(object sender, EventArgs e)
|
||||||
@@ -427,12 +471,12 @@ namespace BealeEngineering.Accounts
|
|||||||
|
|
||||||
var currentSaleInvoice = new Core.Data.Database.Sale.ReadInvoice(sqlConnectionString).BySaleInvoiceId(invoiceId);
|
var currentSaleInvoice = new Core.Data.Database.Sale.ReadInvoice(sqlConnectionString).BySaleInvoiceId(invoiceId);
|
||||||
|
|
||||||
var frmInvoice = new frmSaleInvoice(currentSaleInvoice);
|
var frmInvoice = new frmSaleInvoice(sqlConnectionString, currentSaleInvoice, this);
|
||||||
frmInvoice.ShowDialog();
|
frmInvoice.ShowDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
isDirtySaleInvoice = true;
|
IsDirtySaleInvoice = true;
|
||||||
tabControl1_SelectedIndexChanged(null, null);
|
IsDirtyRefresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
private void dataGridView2_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||||
@@ -453,7 +497,7 @@ namespace BealeEngineering.Accounts
|
|||||||
purchaseOrderBindingSource.DataSource=
|
purchaseOrderBindingSource.DataSource=
|
||||||
poData.OrderByDescending(x => x.PurchaseOrderDate);
|
poData.OrderByDescending(x => x.PurchaseOrderDate);
|
||||||
|
|
||||||
isDirtyClientPo = false;
|
IsDirtyClientPo = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnOpenPo(object sender, EventArgs e)
|
private void btnOpenPo(object sender, EventArgs e)
|
||||||
@@ -465,8 +509,7 @@ namespace BealeEngineering.Accounts
|
|||||||
frmPo.ShowDialog();
|
frmPo.ShowDialog();
|
||||||
btnRefreshClientPo_Click(null, null);
|
btnRefreshClientPo_Click(null, null);
|
||||||
|
|
||||||
isDirtyClientPo = true;
|
IsDirtyClientPo = true;
|
||||||
tabControl1_SelectedIndexChanged(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnAddPurchaseOrder_Click_1(object sender, EventArgs e)
|
private void btnAddPurchaseOrder_Click_1(object sender, EventArgs e)
|
||||||
@@ -474,15 +517,14 @@ namespace BealeEngineering.Accounts
|
|||||||
var frmPo = new frmClientPurchaseOrder(sqlConnectionString, null);
|
var frmPo = new frmClientPurchaseOrder(sqlConnectionString, null);
|
||||||
frmPo.ShowDialog();
|
frmPo.ShowDialog();
|
||||||
|
|
||||||
isDirtyClientPo = true;
|
IsDirtyClientPo = true;
|
||||||
tabControl1_SelectedIndexChanged(null, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnRefreshProjectWork_Click(object sender, EventArgs e)
|
private void btnRefreshProjectWork_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
dataGridView4.DataSource = new Core.Data.Database.Project.ReadProjectWorkItem(sqlConnectionString).Read();
|
dataGridView4.DataSource = new Core.Data.Database.Project.ReadProjectWorkItem(sqlConnectionString).Read();
|
||||||
|
|
||||||
isDirtyProjectWork = false;
|
IsDirtyProjectWork = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void xeroNewInvoiceToolStripMenuItem_Click(object sender, EventArgs e)
|
private void xeroNewInvoiceToolStripMenuItem_Click(object sender, EventArgs e)
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
this.invoiceLineListDataGridView = new System.Windows.Forms.DataGridView();
|
this.invoiceLineListDataGridView = new System.Windows.Forms.DataGridView();
|
||||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||||
this.taxTotalTextBox = new System.Windows.Forms.TextBox();
|
this.taxTotalTextBox = new System.Windows.Forms.TextBox();
|
||||||
|
this.btnDeleteInvoice = new System.Windows.Forms.Button();
|
||||||
this.bsInvoice = new System.Windows.Forms.BindingSource(this.components);
|
this.bsInvoice = new System.Windows.Forms.BindingSource(this.components);
|
||||||
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
@@ -84,7 +85,7 @@
|
|||||||
// contactNameLabel
|
// contactNameLabel
|
||||||
//
|
//
|
||||||
contactNameLabel.AutoSize = true;
|
contactNameLabel.AutoSize = true;
|
||||||
contactNameLabel.Location = new System.Drawing.Point(65, 27);
|
contactNameLabel.Location = new System.Drawing.Point(65, 105);
|
||||||
contactNameLabel.Name = "contactNameLabel";
|
contactNameLabel.Name = "contactNameLabel";
|
||||||
contactNameLabel.Size = new System.Drawing.Size(78, 13);
|
contactNameLabel.Size = new System.Drawing.Size(78, 13);
|
||||||
contactNameLabel.TabIndex = 0;
|
contactNameLabel.TabIndex = 0;
|
||||||
@@ -93,7 +94,7 @@
|
|||||||
// currencyCodeLabel
|
// currencyCodeLabel
|
||||||
//
|
//
|
||||||
currencyCodeLabel.AutoSize = true;
|
currencyCodeLabel.AutoSize = true;
|
||||||
currencyCodeLabel.Location = new System.Drawing.Point(492, 27);
|
currencyCodeLabel.Location = new System.Drawing.Point(454, 27);
|
||||||
currencyCodeLabel.Name = "currencyCodeLabel";
|
currencyCodeLabel.Name = "currencyCodeLabel";
|
||||||
currencyCodeLabel.Size = new System.Drawing.Size(80, 13);
|
currencyCodeLabel.Size = new System.Drawing.Size(80, 13);
|
||||||
currencyCodeLabel.TabIndex = 2;
|
currencyCodeLabel.TabIndex = 2;
|
||||||
@@ -102,7 +103,7 @@
|
|||||||
// dueDateLabel
|
// dueDateLabel
|
||||||
//
|
//
|
||||||
dueDateLabel.AutoSize = true;
|
dueDateLabel.AutoSize = true;
|
||||||
dueDateLabel.Location = new System.Drawing.Point(87, 106);
|
dueDateLabel.Location = new System.Drawing.Point(87, 80);
|
||||||
dueDateLabel.Name = "dueDateLabel";
|
dueDateLabel.Name = "dueDateLabel";
|
||||||
dueDateLabel.Size = new System.Drawing.Size(56, 13);
|
dueDateLabel.Size = new System.Drawing.Size(56, 13);
|
||||||
dueDateLabel.TabIndex = 4;
|
dueDateLabel.TabIndex = 4;
|
||||||
@@ -111,7 +112,7 @@
|
|||||||
// invoiceDateLabel
|
// invoiceDateLabel
|
||||||
//
|
//
|
||||||
invoiceDateLabel.AutoSize = true;
|
invoiceDateLabel.AutoSize = true;
|
||||||
invoiceDateLabel.Location = new System.Drawing.Point(72, 80);
|
invoiceDateLabel.Location = new System.Drawing.Point(72, 54);
|
||||||
invoiceDateLabel.Name = "invoiceDateLabel";
|
invoiceDateLabel.Name = "invoiceDateLabel";
|
||||||
invoiceDateLabel.Size = new System.Drawing.Size(71, 13);
|
invoiceDateLabel.Size = new System.Drawing.Size(71, 13);
|
||||||
invoiceDateLabel.TabIndex = 6;
|
invoiceDateLabel.TabIndex = 6;
|
||||||
@@ -120,7 +121,7 @@
|
|||||||
// invoiceTotalLabel
|
// invoiceTotalLabel
|
||||||
//
|
//
|
||||||
invoiceTotalLabel.AutoSize = true;
|
invoiceTotalLabel.AutoSize = true;
|
||||||
invoiceTotalLabel.Location = new System.Drawing.Point(500, 79);
|
invoiceTotalLabel.Location = new System.Drawing.Point(462, 79);
|
||||||
invoiceTotalLabel.Name = "invoiceTotalLabel";
|
invoiceTotalLabel.Name = "invoiceTotalLabel";
|
||||||
invoiceTotalLabel.Size = new System.Drawing.Size(72, 13);
|
invoiceTotalLabel.Size = new System.Drawing.Size(72, 13);
|
||||||
invoiceTotalLabel.TabIndex = 8;
|
invoiceTotalLabel.TabIndex = 8;
|
||||||
@@ -129,7 +130,7 @@
|
|||||||
// isCreditNoteLabel
|
// isCreditNoteLabel
|
||||||
//
|
//
|
||||||
isCreditNoteLabel.AutoSize = true;
|
isCreditNoteLabel.AutoSize = true;
|
||||||
isCreditNoteLabel.Location = new System.Drawing.Point(498, 107);
|
isCreditNoteLabel.Location = new System.Drawing.Point(460, 107);
|
||||||
isCreditNoteLabel.Name = "isCreditNoteLabel";
|
isCreditNoteLabel.Name = "isCreditNoteLabel";
|
||||||
isCreditNoteLabel.Size = new System.Drawing.Size(74, 13);
|
isCreditNoteLabel.Size = new System.Drawing.Size(74, 13);
|
||||||
isCreditNoteLabel.TabIndex = 10;
|
isCreditNoteLabel.TabIndex = 10;
|
||||||
@@ -147,16 +148,16 @@
|
|||||||
// saleInvoiceNumberLabel
|
// saleInvoiceNumberLabel
|
||||||
//
|
//
|
||||||
saleInvoiceNumberLabel.AutoSize = true;
|
saleInvoiceNumberLabel.AutoSize = true;
|
||||||
saleInvoiceNumberLabel.Location = new System.Drawing.Point(34, 53);
|
saleInvoiceNumberLabel.Location = new System.Drawing.Point(58, 27);
|
||||||
saleInvoiceNumberLabel.Name = "saleInvoiceNumberLabel";
|
saleInvoiceNumberLabel.Name = "saleInvoiceNumberLabel";
|
||||||
saleInvoiceNumberLabel.Size = new System.Drawing.Size(109, 13);
|
saleInvoiceNumberLabel.Size = new System.Drawing.Size(85, 13);
|
||||||
saleInvoiceNumberLabel.TabIndex = 14;
|
saleInvoiceNumberLabel.TabIndex = 14;
|
||||||
saleInvoiceNumberLabel.Text = "Sale Invoice Number:";
|
saleInvoiceNumberLabel.Text = "Invoice Number:";
|
||||||
//
|
//
|
||||||
// statusLabel
|
// statusLabel
|
||||||
//
|
//
|
||||||
statusLabel.AutoSize = true;
|
statusLabel.AutoSize = true;
|
||||||
statusLabel.Location = new System.Drawing.Point(532, 135);
|
statusLabel.Location = new System.Drawing.Point(494, 135);
|
||||||
statusLabel.Name = "statusLabel";
|
statusLabel.Name = "statusLabel";
|
||||||
statusLabel.Size = new System.Drawing.Size(40, 13);
|
statusLabel.Size = new System.Drawing.Size(40, 13);
|
||||||
statusLabel.TabIndex = 16;
|
statusLabel.TabIndex = 16;
|
||||||
@@ -165,7 +166,7 @@
|
|||||||
// taxTotalLabel
|
// taxTotalLabel
|
||||||
//
|
//
|
||||||
taxTotalLabel.AutoSize = true;
|
taxTotalLabel.AutoSize = true;
|
||||||
taxTotalLabel.Location = new System.Drawing.Point(517, 53);
|
taxTotalLabel.Location = new System.Drawing.Point(479, 53);
|
||||||
taxTotalLabel.Name = "taxTotalLabel";
|
taxTotalLabel.Name = "taxTotalLabel";
|
||||||
taxTotalLabel.Size = new System.Drawing.Size(55, 13);
|
taxTotalLabel.Size = new System.Drawing.Size(55, 13);
|
||||||
taxTotalLabel.TabIndex = 18;
|
taxTotalLabel.TabIndex = 18;
|
||||||
@@ -174,7 +175,7 @@
|
|||||||
// contactNameTextBox
|
// contactNameTextBox
|
||||||
//
|
//
|
||||||
this.contactNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "ContactName", true));
|
this.contactNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "ContactName", true));
|
||||||
this.contactNameTextBox.Location = new System.Drawing.Point(149, 24);
|
this.contactNameTextBox.Location = new System.Drawing.Point(149, 102);
|
||||||
this.contactNameTextBox.Name = "contactNameTextBox";
|
this.contactNameTextBox.Name = "contactNameTextBox";
|
||||||
this.contactNameTextBox.Size = new System.Drawing.Size(200, 20);
|
this.contactNameTextBox.Size = new System.Drawing.Size(200, 20);
|
||||||
this.contactNameTextBox.TabIndex = 1;
|
this.contactNameTextBox.TabIndex = 1;
|
||||||
@@ -182,7 +183,7 @@
|
|||||||
// currencyCodeTextBox
|
// currencyCodeTextBox
|
||||||
//
|
//
|
||||||
this.currencyCodeTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "CurrencyCode", true));
|
this.currencyCodeTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "CurrencyCode", true));
|
||||||
this.currencyCodeTextBox.Location = new System.Drawing.Point(578, 24);
|
this.currencyCodeTextBox.Location = new System.Drawing.Point(540, 24);
|
||||||
this.currencyCodeTextBox.Name = "currencyCodeTextBox";
|
this.currencyCodeTextBox.Name = "currencyCodeTextBox";
|
||||||
this.currencyCodeTextBox.Size = new System.Drawing.Size(100, 20);
|
this.currencyCodeTextBox.Size = new System.Drawing.Size(100, 20);
|
||||||
this.currencyCodeTextBox.TabIndex = 3;
|
this.currencyCodeTextBox.TabIndex = 3;
|
||||||
@@ -190,23 +191,23 @@
|
|||||||
// dueDateDateTimePicker
|
// dueDateDateTimePicker
|
||||||
//
|
//
|
||||||
this.dueDateDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.bsInvoice, "DueDate", true));
|
this.dueDateDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.bsInvoice, "DueDate", true));
|
||||||
this.dueDateDateTimePicker.Location = new System.Drawing.Point(149, 102);
|
this.dueDateDateTimePicker.Location = new System.Drawing.Point(149, 76);
|
||||||
this.dueDateDateTimePicker.Name = "dueDateDateTimePicker";
|
this.dueDateDateTimePicker.Name = "dueDateDateTimePicker";
|
||||||
this.dueDateDateTimePicker.Size = new System.Drawing.Size(200, 20);
|
this.dueDateDateTimePicker.Size = new System.Drawing.Size(118, 20);
|
||||||
this.dueDateDateTimePicker.TabIndex = 5;
|
this.dueDateDateTimePicker.TabIndex = 5;
|
||||||
//
|
//
|
||||||
// invoiceDateDateTimePicker
|
// invoiceDateDateTimePicker
|
||||||
//
|
//
|
||||||
this.invoiceDateDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.bsInvoice, "InvoiceDate", true));
|
this.invoiceDateDateTimePicker.DataBindings.Add(new System.Windows.Forms.Binding("Value", this.bsInvoice, "InvoiceDate", true));
|
||||||
this.invoiceDateDateTimePicker.Location = new System.Drawing.Point(149, 76);
|
this.invoiceDateDateTimePicker.Location = new System.Drawing.Point(149, 50);
|
||||||
this.invoiceDateDateTimePicker.Name = "invoiceDateDateTimePicker";
|
this.invoiceDateDateTimePicker.Name = "invoiceDateDateTimePicker";
|
||||||
this.invoiceDateDateTimePicker.Size = new System.Drawing.Size(200, 20);
|
this.invoiceDateDateTimePicker.Size = new System.Drawing.Size(118, 20);
|
||||||
this.invoiceDateDateTimePicker.TabIndex = 7;
|
this.invoiceDateDateTimePicker.TabIndex = 7;
|
||||||
//
|
//
|
||||||
// invoiceTotalTextBox
|
// invoiceTotalTextBox
|
||||||
//
|
//
|
||||||
this.invoiceTotalTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "InvoiceTotal", true));
|
this.invoiceTotalTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "InvoiceTotal", true));
|
||||||
this.invoiceTotalTextBox.Location = new System.Drawing.Point(578, 76);
|
this.invoiceTotalTextBox.Location = new System.Drawing.Point(540, 76);
|
||||||
this.invoiceTotalTextBox.Name = "invoiceTotalTextBox";
|
this.invoiceTotalTextBox.Name = "invoiceTotalTextBox";
|
||||||
this.invoiceTotalTextBox.Size = new System.Drawing.Size(100, 20);
|
this.invoiceTotalTextBox.Size = new System.Drawing.Size(100, 20);
|
||||||
this.invoiceTotalTextBox.TabIndex = 9;
|
this.invoiceTotalTextBox.TabIndex = 9;
|
||||||
@@ -214,7 +215,7 @@
|
|||||||
// isCreditNoteCheckBox
|
// isCreditNoteCheckBox
|
||||||
//
|
//
|
||||||
this.isCreditNoteCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("CheckState", this.bsInvoice, "IsCreditNote", true));
|
this.isCreditNoteCheckBox.DataBindings.Add(new System.Windows.Forms.Binding("CheckState", this.bsInvoice, "IsCreditNote", true));
|
||||||
this.isCreditNoteCheckBox.Location = new System.Drawing.Point(578, 102);
|
this.isCreditNoteCheckBox.Location = new System.Drawing.Point(540, 102);
|
||||||
this.isCreditNoteCheckBox.Name = "isCreditNoteCheckBox";
|
this.isCreditNoteCheckBox.Name = "isCreditNoteCheckBox";
|
||||||
this.isCreditNoteCheckBox.Size = new System.Drawing.Size(104, 24);
|
this.isCreditNoteCheckBox.Size = new System.Drawing.Size(104, 24);
|
||||||
this.isCreditNoteCheckBox.TabIndex = 11;
|
this.isCreditNoteCheckBox.TabIndex = 11;
|
||||||
@@ -232,15 +233,15 @@
|
|||||||
// saleInvoiceNumberTextBox
|
// saleInvoiceNumberTextBox
|
||||||
//
|
//
|
||||||
this.saleInvoiceNumberTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "SaleInvoiceNumber", true));
|
this.saleInvoiceNumberTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "SaleInvoiceNumber", true));
|
||||||
this.saleInvoiceNumberTextBox.Location = new System.Drawing.Point(149, 50);
|
this.saleInvoiceNumberTextBox.Location = new System.Drawing.Point(149, 24);
|
||||||
this.saleInvoiceNumberTextBox.Name = "saleInvoiceNumberTextBox";
|
this.saleInvoiceNumberTextBox.Name = "saleInvoiceNumberTextBox";
|
||||||
this.saleInvoiceNumberTextBox.Size = new System.Drawing.Size(100, 20);
|
this.saleInvoiceNumberTextBox.Size = new System.Drawing.Size(118, 20);
|
||||||
this.saleInvoiceNumberTextBox.TabIndex = 15;
|
this.saleInvoiceNumberTextBox.TabIndex = 15;
|
||||||
//
|
//
|
||||||
// statusTextBox
|
// statusTextBox
|
||||||
//
|
//
|
||||||
this.statusTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "Status", true));
|
this.statusTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "Status", true));
|
||||||
this.statusTextBox.Location = new System.Drawing.Point(578, 132);
|
this.statusTextBox.Location = new System.Drawing.Point(540, 132);
|
||||||
this.statusTextBox.Name = "statusTextBox";
|
this.statusTextBox.Name = "statusTextBox";
|
||||||
this.statusTextBox.Size = new System.Drawing.Size(100, 20);
|
this.statusTextBox.Size = new System.Drawing.Size(100, 20);
|
||||||
this.statusTextBox.TabIndex = 17;
|
this.statusTextBox.TabIndex = 17;
|
||||||
@@ -275,10 +276,11 @@
|
|||||||
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
|
||||||
this.invoiceLineListDataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
this.invoiceLineListDataGridView.DefaultCellStyle = dataGridViewCellStyle2;
|
||||||
this.invoiceLineListDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.invoiceLineListDataGridView.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.invoiceLineListDataGridView.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnEnter;
|
||||||
this.invoiceLineListDataGridView.Location = new System.Drawing.Point(0, 0);
|
this.invoiceLineListDataGridView.Location = new System.Drawing.Point(0, 0);
|
||||||
this.invoiceLineListDataGridView.Name = "invoiceLineListDataGridView";
|
this.invoiceLineListDataGridView.Name = "invoiceLineListDataGridView";
|
||||||
this.invoiceLineListDataGridView.ReadOnly = true;
|
this.invoiceLineListDataGridView.ReadOnly = true;
|
||||||
this.invoiceLineListDataGridView.Size = new System.Drawing.Size(800, 296);
|
this.invoiceLineListDataGridView.Size = new System.Drawing.Size(800, 399);
|
||||||
this.invoiceLineListDataGridView.TabIndex = 18;
|
this.invoiceLineListDataGridView.TabIndex = 18;
|
||||||
//
|
//
|
||||||
// splitContainer1
|
// splitContainer1
|
||||||
@@ -292,6 +294,7 @@
|
|||||||
//
|
//
|
||||||
// splitContainer1.Panel1
|
// splitContainer1.Panel1
|
||||||
//
|
//
|
||||||
|
this.splitContainer1.Panel1.Controls.Add(this.btnDeleteInvoice);
|
||||||
this.splitContainer1.Panel1.Controls.Add(taxTotalLabel);
|
this.splitContainer1.Panel1.Controls.Add(taxTotalLabel);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.taxTotalTextBox);
|
this.splitContainer1.Panel1.Controls.Add(this.taxTotalTextBox);
|
||||||
this.splitContainer1.Panel1.Controls.Add(this.saleInvoiceNumberTextBox);
|
this.splitContainer1.Panel1.Controls.Add(this.saleInvoiceNumberTextBox);
|
||||||
@@ -316,18 +319,28 @@
|
|||||||
// splitContainer1.Panel2
|
// splitContainer1.Panel2
|
||||||
//
|
//
|
||||||
this.splitContainer1.Panel2.Controls.Add(this.invoiceLineListDataGridView);
|
this.splitContainer1.Panel2.Controls.Add(this.invoiceLineListDataGridView);
|
||||||
this.splitContainer1.Size = new System.Drawing.Size(800, 475);
|
this.splitContainer1.Size = new System.Drawing.Size(800, 578);
|
||||||
this.splitContainer1.SplitterDistance = 175;
|
this.splitContainer1.SplitterDistance = 175;
|
||||||
this.splitContainer1.TabIndex = 19;
|
this.splitContainer1.TabIndex = 19;
|
||||||
//
|
//
|
||||||
// taxTotalTextBox
|
// taxTotalTextBox
|
||||||
//
|
//
|
||||||
this.taxTotalTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "TaxTotal", true));
|
this.taxTotalTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.bsInvoice, "TaxTotal", true));
|
||||||
this.taxTotalTextBox.Location = new System.Drawing.Point(578, 50);
|
this.taxTotalTextBox.Location = new System.Drawing.Point(540, 50);
|
||||||
this.taxTotalTextBox.Name = "taxTotalTextBox";
|
this.taxTotalTextBox.Name = "taxTotalTextBox";
|
||||||
this.taxTotalTextBox.Size = new System.Drawing.Size(100, 20);
|
this.taxTotalTextBox.Size = new System.Drawing.Size(100, 20);
|
||||||
this.taxTotalTextBox.TabIndex = 19;
|
this.taxTotalTextBox.TabIndex = 19;
|
||||||
//
|
//
|
||||||
|
// btnDeleteInvoice
|
||||||
|
//
|
||||||
|
this.btnDeleteInvoice.Location = new System.Drawing.Point(693, 24);
|
||||||
|
this.btnDeleteInvoice.Name = "btnDeleteInvoice";
|
||||||
|
this.btnDeleteInvoice.Size = new System.Drawing.Size(77, 20);
|
||||||
|
this.btnDeleteInvoice.TabIndex = 20;
|
||||||
|
this.btnDeleteInvoice.Text = "Delete";
|
||||||
|
this.btnDeleteInvoice.UseVisualStyleBackColor = true;
|
||||||
|
this.btnDeleteInvoice.Click += new System.EventHandler(this.btnDeleteInvoice_Click);
|
||||||
|
//
|
||||||
// bsInvoice
|
// bsInvoice
|
||||||
//
|
//
|
||||||
this.bsInvoice.DataSource = typeof(BealeEngineering.Core.Model.Sale.Invoice);
|
this.bsInvoice.DataSource = typeof(BealeEngineering.Core.Model.Sale.Invoice);
|
||||||
@@ -354,38 +367,38 @@
|
|||||||
// dataGridViewTextBoxColumn4
|
// dataGridViewTextBoxColumn4
|
||||||
//
|
//
|
||||||
this.dataGridViewTextBoxColumn4.DataPropertyName = "Quantity";
|
this.dataGridViewTextBoxColumn4.DataPropertyName = "Quantity";
|
||||||
this.dataGridViewTextBoxColumn4.HeaderText = "Quantity";
|
this.dataGridViewTextBoxColumn4.HeaderText = "Qty.";
|
||||||
this.dataGridViewTextBoxColumn4.MinimumWidth = 30;
|
this.dataGridViewTextBoxColumn4.MinimumWidth = 35;
|
||||||
this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
|
this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
|
||||||
this.dataGridViewTextBoxColumn4.ReadOnly = true;
|
this.dataGridViewTextBoxColumn4.ReadOnly = true;
|
||||||
this.dataGridViewTextBoxColumn4.Width = 30;
|
this.dataGridViewTextBoxColumn4.Width = 35;
|
||||||
//
|
//
|
||||||
// dataGridViewTextBoxColumn5
|
// dataGridViewTextBoxColumn5
|
||||||
//
|
//
|
||||||
this.dataGridViewTextBoxColumn5.DataPropertyName = "UnitAmount";
|
this.dataGridViewTextBoxColumn5.DataPropertyName = "UnitAmount";
|
||||||
this.dataGridViewTextBoxColumn5.HeaderText = "Unit Amount";
|
this.dataGridViewTextBoxColumn5.HeaderText = "Unit Amount";
|
||||||
this.dataGridViewTextBoxColumn5.MinimumWidth = 40;
|
this.dataGridViewTextBoxColumn5.MinimumWidth = 60;
|
||||||
this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
|
this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
|
||||||
this.dataGridViewTextBoxColumn5.ReadOnly = true;
|
this.dataGridViewTextBoxColumn5.ReadOnly = true;
|
||||||
this.dataGridViewTextBoxColumn5.Width = 40;
|
this.dataGridViewTextBoxColumn5.Width = 60;
|
||||||
//
|
//
|
||||||
// dataGridViewTextBoxColumn7
|
// dataGridViewTextBoxColumn7
|
||||||
//
|
//
|
||||||
this.dataGridViewTextBoxColumn7.DataPropertyName = "AccountCode";
|
this.dataGridViewTextBoxColumn7.DataPropertyName = "AccountCode";
|
||||||
this.dataGridViewTextBoxColumn7.HeaderText = "Account Code";
|
this.dataGridViewTextBoxColumn7.HeaderText = "Account Code";
|
||||||
this.dataGridViewTextBoxColumn7.MinimumWidth = 50;
|
this.dataGridViewTextBoxColumn7.MinimumWidth = 80;
|
||||||
this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
|
this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
|
||||||
this.dataGridViewTextBoxColumn7.ReadOnly = true;
|
this.dataGridViewTextBoxColumn7.ReadOnly = true;
|
||||||
this.dataGridViewTextBoxColumn7.Width = 50;
|
this.dataGridViewTextBoxColumn7.Width = 80;
|
||||||
//
|
//
|
||||||
// dataGridViewTextBoxColumn8
|
// dataGridViewTextBoxColumn8
|
||||||
//
|
//
|
||||||
this.dataGridViewTextBoxColumn8.DataPropertyName = "TaxType";
|
this.dataGridViewTextBoxColumn8.DataPropertyName = "TaxType";
|
||||||
this.dataGridViewTextBoxColumn8.HeaderText = "Tax Type";
|
this.dataGridViewTextBoxColumn8.HeaderText = "Tax Type";
|
||||||
this.dataGridViewTextBoxColumn8.MinimumWidth = 50;
|
this.dataGridViewTextBoxColumn8.MinimumWidth = 80;
|
||||||
this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
|
this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
|
||||||
this.dataGridViewTextBoxColumn8.ReadOnly = true;
|
this.dataGridViewTextBoxColumn8.ReadOnly = true;
|
||||||
this.dataGridViewTextBoxColumn8.Width = 50;
|
this.dataGridViewTextBoxColumn8.Width = 80;
|
||||||
//
|
//
|
||||||
// dataGridViewTextBoxColumn9
|
// dataGridViewTextBoxColumn9
|
||||||
//
|
//
|
||||||
@@ -400,13 +413,14 @@
|
|||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(800, 475);
|
this.ClientSize = new System.Drawing.Size(800, 578);
|
||||||
this.Controls.Add(this.splitContainer1);
|
this.Controls.Add(this.splitContainer1);
|
||||||
this.MaximizeBox = false;
|
this.MaximizeBox = false;
|
||||||
this.MinimizeBox = false;
|
this.MinimizeBox = false;
|
||||||
this.Name = "frmSaleInvoice";
|
this.Name = "frmSaleInvoice";
|
||||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||||
this.Text = "SaleInvoice";
|
this.Text = "Sales Invoice";
|
||||||
|
this.Load += new System.EventHandler(this.frmSaleInvoice_Load);
|
||||||
((System.ComponentModel.ISupportInitialize)(this.invoiceLineListBindingSource)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.invoiceLineListBindingSource)).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.invoiceLineListDataGridView)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.invoiceLineListDataGridView)).EndInit();
|
||||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||||
@@ -443,5 +457,6 @@
|
|||||||
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
|
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
|
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
|
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
|
||||||
|
private System.Windows.Forms.Button btnDeleteInvoice;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using BealeEngineering.Core.Model.Sale;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@@ -12,12 +13,72 @@ namespace BealeEngineering.Accounts
|
|||||||
{
|
{
|
||||||
public partial class frmSaleInvoice : Form
|
public partial class frmSaleInvoice : Form
|
||||||
{
|
{
|
||||||
public frmSaleInvoice(Core.Model.Sale.Invoice invoice = null)
|
private Core.Model.Sale.Invoice invoice;
|
||||||
|
private string sqlConnectionString;
|
||||||
|
private frmMain owner;
|
||||||
|
|
||||||
|
public frmSaleInvoice(string sqlConnectionString, Core.Model.Sale.Invoice invoice = null, frmMain owner = null)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
bsInvoice.DataSource = invoice;
|
this.sqlConnectionString = sqlConnectionString;
|
||||||
invoiceLineListBindingSource.DataSource = invoice.InvoiceLineList;
|
|
||||||
|
if (owner != null)
|
||||||
|
{
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invoice == null)
|
||||||
|
{
|
||||||
|
this.invoice = new Core.Model.Sale.Invoice();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.invoice = invoice;
|
||||||
|
}
|
||||||
|
|
||||||
|
bsInvoice.DataSource = this.invoice;
|
||||||
|
invoiceLineListBindingSource.DataSource = this.invoice.InvoiceLineList;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void frmSaleInvoice_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnDeleteInvoice_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
string dialogText = "Delete invoice?";
|
||||||
|
|
||||||
|
DialogResult dialogResult = MessageBox.Show(dialogText, "Delete Invoice", MessageBoxButtons.OKCancel);
|
||||||
|
if (dialogResult == DialogResult.OK)
|
||||||
|
{
|
||||||
|
if (invoice.SaleInvoiceIdIsSet)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var inst = new Core.Logic.Sale.DeleteInvoice(sqlConnectionString);
|
||||||
|
bool ack = inst.Execute(invoice.SaleInvoiceID);
|
||||||
|
owner.IsDirtySaleInvoice = true;
|
||||||
|
if (ack == false)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Invoice deletion failed: " + inst.ErrorMessage);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show("Exception caught: " + ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,7 +66,9 @@
|
|||||||
<Compile Include="Data\Database\Client\ReadPurchaseOrder.cs" />
|
<Compile Include="Data\Database\Client\ReadPurchaseOrder.cs" />
|
||||||
<Compile Include="Data\Database\Client\ReadPurchaseOrderAllocation.cs" />
|
<Compile Include="Data\Database\Client\ReadPurchaseOrderAllocation.cs" />
|
||||||
<Compile Include="Data\Database\Client\ReadPurchaseOrderLineFacility.cs" />
|
<Compile Include="Data\Database\Client\ReadPurchaseOrderLineFacility.cs" />
|
||||||
<Compile Include="Data\Database\Client\ReadSaleInvoiceAllocation.cs" />
|
<Compile Include="Data\Database\Sale\DeleteInvoiceHeader.cs" />
|
||||||
|
<Compile Include="Data\Database\Sale\DeleteInvoiceLine.cs" />
|
||||||
|
<Compile Include="Data\Database\Sale\ReadSaleInvoiceAllocation.cs" />
|
||||||
<Compile Include="Data\Database\Client\UpdatePurchaseOrder.cs" />
|
<Compile Include="Data\Database\Client\UpdatePurchaseOrder.cs" />
|
||||||
<Compile Include="Data\Database\Contact\ReadContactList.cs" />
|
<Compile Include="Data\Database\Contact\ReadContactList.cs" />
|
||||||
<Compile Include="Data\Database\Contact\UpdateContact.cs" />
|
<Compile Include="Data\Database\Contact\UpdateContact.cs" />
|
||||||
@@ -87,7 +89,8 @@
|
|||||||
<Compile Include="Logic\Export\ExcelInvoiceFlatFile.cs" />
|
<Compile Include="Logic\Export\ExcelInvoiceFlatFile.cs" />
|
||||||
<Compile Include="Logic\Export\XeroInvoiceFlatFile.cs" />
|
<Compile Include="Logic\Export\XeroInvoiceFlatFile.cs" />
|
||||||
<Compile Include="Logic\Prototype\ObjectExtensions.cs" />
|
<Compile Include="Logic\Prototype\ObjectExtensions.cs" />
|
||||||
<Compile Include="Logic\Sale\SaleInvoiceAssign.cs" />
|
<Compile Include="Logic\Sale\AssignInvoice.cs" />
|
||||||
|
<Compile Include="Logic\Sale\DeleteInvoice.cs" />
|
||||||
<Compile Include="Logic\Validate\CientPurchaseOrder.cs" />
|
<Compile Include="Logic\Validate\CientPurchaseOrder.cs" />
|
||||||
<Compile Include="Model\Client\PurchaseOrderAllocation.cs" />
|
<Compile Include="Model\Client\PurchaseOrderAllocation.cs" />
|
||||||
<Compile Include="Model\Contact\Address.cs" />
|
<Compile Include="Model\Contact\Address.cs" />
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BealeEngineering.Core.Data.Database.Sale
|
||||||
|
{
|
||||||
|
public class DeleteInvoiceHeader : Connection
|
||||||
|
{
|
||||||
|
public DeleteInvoiceHeader(string sqlConnectionString) : base(sqlConnectionString)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ByInvoiceId(int invoiceId)
|
||||||
|
{
|
||||||
|
string sqlWhere = "SaleInvoiceID = @invoiceId";
|
||||||
|
|
||||||
|
return Execute(sqlWhere, new Dictionary<string, object> { { "@invoiceId", invoiceId } });
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ByInvoiceNumber(string invoiceNumber)
|
||||||
|
{
|
||||||
|
string sqlWhere = "SaleInvoiceNumber = @invoiceNumber";
|
||||||
|
|
||||||
|
return Execute(sqlWhere, new Dictionary<string, object> { { "@invoiceNumber", invoiceNumber } } );
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool Execute(string sqlWhere, Dictionary<string, object> paramters)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(sqlWhere))
|
||||||
|
{
|
||||||
|
throw new Exception("Where condition to SQL string required");
|
||||||
|
}
|
||||||
|
|
||||||
|
string sql = @"
|
||||||
|
DELETE
|
||||||
|
FROM SaleInvoice
|
||||||
|
WHERE " + sqlWhere;
|
||||||
|
|
||||||
|
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
// delete invoice header
|
||||||
|
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||||
|
{
|
||||||
|
foreach (var item in paramters)
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue(item.Key, item.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int effected = cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
if (effected > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BealeEngineering.Core.Data.Database.Sale
|
||||||
|
{
|
||||||
|
public class DeleteInvoiceLine : Connection
|
||||||
|
{
|
||||||
|
public DeleteInvoiceLine(string sqlConnectionString) : base(sqlConnectionString)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes sales invoice line based on Sale Invoice ID
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="invoiceNumber">Sale Invoice ID</param>
|
||||||
|
/// <returns>Number of rows effected</returns>
|
||||||
|
public int ByInvoiceId(int invoiceId)
|
||||||
|
{
|
||||||
|
string sqlWhere = " SaleInvoiceID = @invoiceId";
|
||||||
|
|
||||||
|
return Execute(sqlWhere, new Dictionary<string, object> { { "@invoiceId", invoiceId } });
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Deletes sales invoice line based on Sale Invoice Number
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="invoiceNumber">Sale Invoice Number</param>
|
||||||
|
/// <returns>Number of rows effected</returns>
|
||||||
|
public int ByInvoiceNumber(string invoiceNumber)
|
||||||
|
{
|
||||||
|
string sqlWhere = @"(
|
||||||
|
SELECT SaleInvoiceID
|
||||||
|
FROM SaleInvoice
|
||||||
|
WHERE (SaleInvoiceNumber = @invoiceNumber)
|
||||||
|
) IS NOT NULL
|
||||||
|
AND (
|
||||||
|
SaleInvoiceID = ISNULL((
|
||||||
|
SELECT SaleInvoiceID
|
||||||
|
FROM SaleInvoice
|
||||||
|
WHERE (SaleInvoiceNumber = @invoiceNumber)
|
||||||
|
), 0)
|
||||||
|
) ";
|
||||||
|
|
||||||
|
return Execute(sqlWhere, new Dictionary<string, object> { { "@invoiceNumber", invoiceNumber } });
|
||||||
|
}
|
||||||
|
|
||||||
|
private int Execute(string sqlWhere, Dictionary<string, object> parameters)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(sqlWhere))
|
||||||
|
{
|
||||||
|
throw new Exception("Where condition to SQL string required");
|
||||||
|
}
|
||||||
|
|
||||||
|
string sql = @"
|
||||||
|
DELETE
|
||||||
|
FROM SaleInvoiceLine
|
||||||
|
WHERE " + sqlWhere;
|
||||||
|
|
||||||
|
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
using (SqlCommand cmd = new SqlCommand(sql, conn))
|
||||||
|
{
|
||||||
|
foreach (var item in parameters)
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue(item.Key, item.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
int effected = cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
return effected;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,7 +5,7 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace BealeEngineering.Core.Data.Database.Client
|
namespace BealeEngineering.Core.Data.Database.Sale
|
||||||
{
|
{
|
||||||
public class ReadSaleInvoiceAllocation : Connection
|
public class ReadSaleInvoiceAllocation : Connection
|
||||||
{
|
{
|
||||||
@@ -13,6 +13,44 @@ namespace BealeEngineering.Core.Data.Database.Client
|
|||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the client purchase order line ID that has been assigned to an invoice
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="salesInvoiceId">Sales invoice Id</param>
|
||||||
|
/// <returns>Client purchase order line ID where one has been assigned, else null</returns>
|
||||||
|
public int? GetPurchaseOrderLineId(int salesInvoiceId)
|
||||||
|
{
|
||||||
|
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
|
||||||
|
using (SqlCommand cmd = new SqlCommand(@"
|
||||||
|
SELECT ClientPurchaseOrderLineID
|
||||||
|
FROM ClientPurchaseOrderLineSalesInvoice
|
||||||
|
WHERE SaleInvoiceID = @salesInvoiceId
|
||||||
|
", conn))
|
||||||
|
{
|
||||||
|
cmd.Parameters.AddWithValue("@salesInvoiceId", salesInvoiceId);
|
||||||
|
|
||||||
|
object obj = cmd.ExecuteScalar();
|
||||||
|
|
||||||
|
if (obj == null || obj == DBNull.Value)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (int)obj;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a count of invoices that have not been allocated to a client purchase order line
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>Count of unallocated sales invoices</returns>
|
||||||
public int GetUnallocatedInvoiceCount()
|
public int GetUnallocatedInvoiceCount()
|
||||||
{
|
{
|
||||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||||
@@ -33,6 +71,11 @@ namespace BealeEngineering.Core.Data.Database.Client
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets list of invoices that have not been allocated to a client purchase order line
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>List of sales invoice numbers</returns>
|
||||||
public List<string> GetUnallocatedInvoice()
|
public List<string> GetUnallocatedInvoice()
|
||||||
{
|
{
|
||||||
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
using (SqlConnection conn = new SqlConnection(sqlConnectionString))
|
||||||
@@ -27,7 +27,7 @@ namespace BealeEngineering.Core.Logic.Client
|
|||||||
Init();
|
Init();
|
||||||
|
|
||||||
// get list of unallocated invoices
|
// get list of unallocated invoices
|
||||||
var poAlloInstance = new Data.Database.Client.ReadSaleInvoiceAllocation(SqlConnectionString);
|
var poAlloInstance = new Data.Database.Sale.ReadSaleInvoiceAllocation(SqlConnectionString);
|
||||||
var invoiceNumberList = poAlloInstance.GetUnallocatedInvoice();
|
var invoiceNumberList = poAlloInstance.GetUnallocatedInvoice();
|
||||||
|
|
||||||
// nothing to allocate
|
// nothing to allocate
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ using System.Transactions;
|
|||||||
|
|
||||||
namespace BealeEngineering.Core.Logic.Sale
|
namespace BealeEngineering.Core.Logic.Sale
|
||||||
{
|
{
|
||||||
public class SaleInvoiceAssign
|
public class AssignInvoice
|
||||||
{
|
{
|
||||||
string statusModified = new Data.SaleInvoiceFormat().ReadStatusStringModified();
|
string statusModified = new Data.SaleInvoiceFormat().ReadStatusStringModified();
|
||||||
string statusNew = new Data.SaleInvoiceFormat().ReadStatusStringNew();
|
string statusNew = new Data.SaleInvoiceFormat().ReadStatusStringNew();
|
||||||
@@ -17,7 +17,7 @@ namespace BealeEngineering.Core.Logic.Sale
|
|||||||
DateTime timeCheckPostpone = new DateTime();
|
DateTime timeCheckPostpone = new DateTime();
|
||||||
int timeCheckPostponeMinutes = 15;
|
int timeCheckPostponeMinutes = 15;
|
||||||
|
|
||||||
public SaleInvoiceAssign(string sqlConnectionString)
|
public AssignInvoice(string sqlConnectionString)
|
||||||
{
|
{
|
||||||
this.sqlConnectionString = sqlConnectionString;
|
this.sqlConnectionString = sqlConnectionString;
|
||||||
}
|
}
|
||||||
@@ -253,5 +253,16 @@ namespace BealeEngineering.Core.Logic.Sale
|
|||||||
{
|
{
|
||||||
timeCheckPostpone = DateTime.Now.AddMinutes(timeCheckPostponeMinutes);
|
timeCheckPostpone = DateTime.Now.AddMinutes(timeCheckPostponeMinutes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks if a sales invoice is assigned to a purchase order line
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="salesInvoiceId">Sales invoice Id</param>
|
||||||
|
/// <returns>Purchase order line Id if true, null if false</returns>
|
||||||
|
public int? IsAssigned(int salesInvoiceId)
|
||||||
|
{
|
||||||
|
return new Data.Database.Sale.ReadSaleInvoiceAllocation(sqlConnectionString).GetPurchaseOrderLineId(salesInvoiceId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,71 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Transactions;
|
||||||
|
|
||||||
|
namespace BealeEngineering.Core.Logic.Sale
|
||||||
|
{
|
||||||
|
public class DeleteInvoice
|
||||||
|
{
|
||||||
|
private string sqlConnectionString;
|
||||||
|
|
||||||
|
public DeleteInvoice(string sqlConnectionString)
|
||||||
|
{
|
||||||
|
this.sqlConnectionString = sqlConnectionString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ErrorMessage { get; private set; }
|
||||||
|
|
||||||
|
private void Init()
|
||||||
|
{
|
||||||
|
ErrorMessage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Execute(int saleInvoiceId)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
|
using (TransactionScope scope = new TransactionScope())
|
||||||
|
{
|
||||||
|
// check for assigned purchase order line
|
||||||
|
var assignedPo = new Data.Database.Sale.ReadSaleInvoiceAllocation(sqlConnectionString).GetPurchaseOrderLineId(saleInvoiceId);
|
||||||
|
if (assignedPo != null)
|
||||||
|
{
|
||||||
|
ErrorMessage = "Invoice is assigned to Purchase Order Line ID:" + (int)assignedPo;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
int linesEffected = 0;
|
||||||
|
bool headerDeleted = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// delete invoice lines
|
||||||
|
linesEffected = new Data.Database.Sale.DeleteInvoiceLine(sqlConnectionString).ByInvoiceId(saleInvoiceId);
|
||||||
|
|
||||||
|
// delete invoice header
|
||||||
|
headerDeleted = new Data.Database.Sale.DeleteInvoiceHeader(sqlConnectionString).ByInvoiceId(saleInvoiceId);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
ErrorMessage = "Sale Invoice delete failed: " + ex.Message;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (headerDeleted)
|
||||||
|
{
|
||||||
|
scope.Complete();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
scope.Dispose();
|
||||||
|
ErrorMessage = "Sale Invoice delete failed";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -9,21 +9,34 @@ namespace BealeEngineering.Core.Model.Client
|
|||||||
public class PurchaseOrderAllocation
|
public class PurchaseOrderAllocation
|
||||||
{
|
{
|
||||||
public DateTime PurchaseOrderDate { get; set; }
|
public DateTime PurchaseOrderDate { get; set; }
|
||||||
|
|
||||||
public string WorkNumber { get; set; }
|
public string WorkNumber { get; set; }
|
||||||
|
|
||||||
public string ContactName { get; set; }
|
public string ContactName { get; set; }
|
||||||
|
|
||||||
public string ProjectTitle { get; set; }
|
public string ProjectTitle { get; set; }
|
||||||
|
|
||||||
public string WorkTitle { get; set; }
|
public string WorkTitle { get; set; }
|
||||||
|
|
||||||
public string WorkDescription { get; set; }
|
public string WorkDescription { get; set; }
|
||||||
|
|
||||||
public string PurchaseOrderReference { get; set; }
|
public string PurchaseOrderReference { get; set; }
|
||||||
|
|
||||||
public int PurchaseOrderLineID { get; set; }
|
public int PurchaseOrderLineID { get; set; }
|
||||||
|
|
||||||
public int PurchaseOrderLineNumber { get; set; }
|
public int PurchaseOrderLineNumber { get; set; }
|
||||||
|
|
||||||
public string PurchaseOrderLineDescription { get; set; }
|
public string PurchaseOrderLineDescription { get; set; }
|
||||||
|
|
||||||
public decimal PurchaseOrderLineNetAmount { get; set; }
|
public decimal PurchaseOrderLineNetAmount { get; set; }
|
||||||
|
|
||||||
public decimal InvoicedAmount { get; set; }
|
public decimal InvoicedAmount { get; set; }
|
||||||
|
|
||||||
public decimal PurchaseOrderLineFacility
|
public decimal PurchaseOrderLineFacility
|
||||||
{
|
{
|
||||||
get { return PurchaseOrderLineNetAmount - InvoicedAmount; }
|
get { return PurchaseOrderLineNetAmount - InvoicedAmount; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PurchaseOrderIsClosed { get; set; }
|
public bool PurchaseOrderIsClosed { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,8 +10,18 @@ namespace BealeEngineering.Core.Model.Sale
|
|||||||
public class InvoiceHeader : ValidateModel
|
public class InvoiceHeader : ValidateModel
|
||||||
{
|
{
|
||||||
private DateTime? dueDate = null;
|
private DateTime? dueDate = null;
|
||||||
|
private int? saleInvoiceId = null;
|
||||||
|
|
||||||
public int SaleInvoiceID { get; set; }
|
public int SaleInvoiceID
|
||||||
|
{
|
||||||
|
get { return saleInvoiceId.GetValueOrDefault(); }
|
||||||
|
set { saleInvoiceId = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SaleInvoiceIdIsSet
|
||||||
|
{
|
||||||
|
get { return saleInvoiceId != null; }
|
||||||
|
}
|
||||||
|
|
||||||
[Required()]
|
[Required()]
|
||||||
public string ContactName { get; set; }
|
public string ContactName { get; set; }
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ namespace BealeEngineering.Core.Test.Client
|
|||||||
}
|
}
|
||||||
public void GetUnallocatedPo()
|
public void GetUnallocatedPo()
|
||||||
{
|
{
|
||||||
var readPoAllo = new Data.Database.Client.ReadSaleInvoiceAllocation(SqlConnectionString);
|
var readPoAllo = new Data.Database.Sale.ReadSaleInvoiceAllocation(SqlConnectionString);
|
||||||
var test = readPoAllo.GetUnallocatedInvoice();
|
var test = readPoAllo.GetUnallocatedInvoice();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user