public void deleteSalesLine(GoodsIssueLine giDeletedLine, bool bDeleteLastLine) { bool bDeleteControl = false; for (int iLines = 0; iLines < aGoodsLines.Length; iLines++) { GoodsIssueLine giThisline = aGoodsLines[iLines]; if (iLines != aGoodsLines.Length - 1 || bDeleteLastLine) //Never delete the last row { if (giDeletedLine.Name == giThisline.Name) { bDeleteControl = true; this.pnlDetails.Controls.Remove(giDeletedLine); if (iLines != aGoodsLines.Length - 1) { aGoodsLines[iLines + 1].txtCode.Focus(); // focus on the next line } } if (bDeleteControl && iLines != aGoodsLines.Length - 1) //resize the line array { aGoodsLines[iLines] = aGoodsLines[iLines + 1]; //Move all the controls one up in the list aGoodsLines[iLines + 1].Location = new Point(aGoodsLines[iLines + 1].Location.X, aGoodsLines[iLines + 1].Location.Y - 20); // move location of control to new position aGoodsLines[iLines + 1].iLineIndex--;//sync the lineindex of the control array } } } //addTotals(); if (bDeleteControl)//update the line array { Array.Resize<GoodsIssueLine>(ref aGoodsLines, aGoodsLines.Length - 1); iLineRowIndex--; } }
public void AddSalesLine(GoodsIssueLine giNewLine) { Array.Resize<GoodsIssueLine>(ref aGoodsLines, aGoodsLines.Length + 1); aGoodsLines[aGoodsLines.Length - 1] = giNewLine; giNewLine.Top = 17 + ((iLineRowIndex) * 20); giNewLine.Left = 4; if (giNewLine.txtStore.Text == "") { giNewLine.txtStore.Text = Global.sDefaultStore; } giNewLine.TabIndex = 50 + aGoodsLines.Length; giNewLine.TabStop = true; giNewLine.iLineIndex = aGoodsLines.Length - 1; giNewLine.Name = "slNewLine_" + (aGoodsLines.Length - 1).ToString(); this.pnlDetails.Controls.Add(giNewLine); giNewLine.BringToFront(); iLineRowIndex++; }
private void loadReturnItemsGrid(string sDocumentNumber) { dgReturnItems.Rows.Clear(); string sLastItemCode = ""; double dQtyAvaliableToReturn = 0; string sStore = ""; string sDescription = ""; string sItemCode = ""; string sItemUnit = ""; string sCostPerUnit = ""; string sErrorMessage = ""; string sItemType = ""; for (int iLines = 0; iLines < aGoodsLines.Length; iLines++) { GoodsIssueLine giThisline = aGoodsLines[iLines]; this.pnlDetails.Controls.Remove(giThisline); } aGoodsLines = new GoodsIssueLine[0]; iLineRowIndex = 0; PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr); oConn.Open(); string sSql = "Select * from SOLAL where DocumentNumber = '" + sDocumentNumber +"' order by ItemCode"; PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql,oConn).ExecuteReader(); while(rdReader.Read()) { if (Convert.ToDouble(rdReader["Quantity"].ToString()) > 0) { //Add Line in Issue inventory GoodsIssueLine giNewLine = new GoodsIssueLine(); if (rdReader["ErrorMessage"].ToString().Trim() == "") { giNewLine.txtCode.Text = rdReader["ItemCode"].ToString().Trim(); giNewLine.txtStore.Text = rdReader["StoreCode"].ToString().Trim(); giNewLine.txtDescription.Text = rdReader["ItemDescription"].ToString().Trim(); giNewLine.txtUnit.Text = rdReader["ItemUnit"].ToString().Trim(); giNewLine.txtExcPrice.Text = rdReader["CostPerunit"].ToString().Trim(); giNewLine.txtQuantity.Text = rdReader["Quantity"].ToString(); giNewLine.txtItemType.Text = rdReader["ItemType"].ToString(); giNewLine.txtErrorCode.Text = ""; giNewLine.txtCode.ReadOnly = true; giNewLine.txtCode.BackColor = System.Drawing.Color.White; giNewLine.cmdCodeSearch.Visible = false; giNewLine.txtStore.ReadOnly = true; giNewLine.cmdSearchStore.Visible = false; giNewLine.txtDescription.ReadOnly = true; giNewLine.txtDescription.BackColor = System.Drawing.Color.White; giNewLine.txtUnit.ReadOnly = true; giNewLine.txtQuantity.ReadOnly = true; giNewLine.txtQuantity.BackColor = System.Drawing.Color.White; giNewLine.picDelete.Visible = false; } else { giNewLine.txtCode.Text = rdReader["ItemCode"].ToString().Trim(); giNewLine.txtStore.Text = rdReader["StoreCode"].ToString().Trim(); giNewLine.txtDescription.Text = rdReader["ItemDescription"].ToString().Trim(); giNewLine.txtUnit.Text = rdReader["ItemUnit"].ToString().Trim(); giNewLine.txtExcPrice.Text = rdReader["CostPerunit"].ToString().Trim(); giNewLine.txtQuantity.Text = rdReader["Quantity"].ToString(); giNewLine.txtErrorCode.Text = rdReader["ErrorMessage"].ToString().Trim(); giNewLine.txtItemType.Text = rdReader["ItemType"].ToString().Trim(); giNewLine.BackColor = System.Drawing.Color.Red; cmdSaveDocument.Enabled = true; giNewLine.picInfo.Visible = true; } AddSalesLine(giNewLine); } //Add Lines in Return Items DataGrid if (sLastItemCode != rdReader["ItemCode"].ToString().Trim() && sLastItemCode != "") { if (sErrorMessage == "") { int n = dgReturnItems.Rows.Add(); sLastItemCode = rdReader["ItemCode"].ToString().Trim(); dgReturnItems.Rows[n].Cells["clStore"].Value = sStore; dgReturnItems.Rows[n].Cells["clCode"].Value = sItemCode; dgReturnItems.Rows[n].Cells["clDescription"].Value = sDescription; dgReturnItems.Rows[n].Cells["clQtyIssued"].Value = dQtyAvaliableToReturn.ToString(); dgReturnItems.Rows[n].Cells["clQtyIssued"].Style.Alignment = DataGridViewContentAlignment.MiddleRight; dgReturnItems.Rows[n].Cells["clQtyRetuned"].Value = "0"; dgReturnItems.Rows[n].Cells["clQtyRetuned"].Style.Alignment = DataGridViewContentAlignment.MiddleRight; dgReturnItems.Rows[n].Cells["clCostPerUnit"].Value = sCostPerUnit; dgReturnItems.Rows[n].Cells["clItemUnit"].Value = sItemUnit; dgReturnItems.Rows[n].Cells["clItemType"].Value = sItemType; sLastItemCode = rdReader["ItemCode"].ToString().Trim(); sStore = rdReader["StoreCode"].ToString().Trim(); sItemCode = rdReader["ItemCode"].ToString().Trim(); sDescription = rdReader["ItemDescription"].ToString().Trim(); dQtyAvaliableToReturn = Convert.ToDouble(rdReader["Quantity"].ToString()); sCostPerUnit = rdReader["CostPerunit"].ToString().Trim(); sItemUnit = rdReader["ItemUnit"].ToString().Trim(); sErrorMessage = rdReader["ErrorMessage"].ToString().Trim(); sItemType = rdReader["ItemType"].ToString(); } else { sLastItemCode = rdReader["ItemCode"].ToString().Trim(); sStore = rdReader["StoreCode"].ToString().Trim(); sItemCode = rdReader["ItemCode"].ToString().Trim(); sDescription = rdReader["ItemDescription"].ToString().Trim(); dQtyAvaliableToReturn = Convert.ToDouble(rdReader["Quantity"].ToString()); sCostPerUnit = rdReader["CostPerunit"].ToString().Trim(); sItemUnit = rdReader["ItemUnit"].ToString().Trim(); sErrorMessage = rdReader["ErrorMessage"].ToString().Trim(); sItemType = rdReader["ItemType"].ToString(); } } else { if (sLastItemCode == "") { sStore = rdReader["StoreCode"].ToString().Trim(); sItemCode = rdReader["ItemCode"].ToString().Trim(); sDescription = rdReader["ItemDescription"].ToString().Trim(); sCostPerUnit = rdReader["CostPerunit"].ToString().Trim(); sItemUnit = rdReader["ItemUnit"].ToString().Trim(); sLastItemCode = rdReader["ItemCode"].ToString().Trim(); sErrorMessage = rdReader["ErrorMessage"].ToString().Trim(); sItemType = rdReader["ItemType"].ToString(); } dQtyAvaliableToReturn = dQtyAvaliableToReturn + Convert.ToDouble(rdReader["Quantity"].ToString()); } } rdReader.Close(); if (sErrorMessage == "") { int i = dgReturnItems.Rows.Add(); dgReturnItems.Rows[i].Cells["clStore"].Value = sStore; dgReturnItems.Rows[i].Cells["clCode"].Value = sItemCode; dgReturnItems.Rows[i].Cells["clDescription"].Value = sDescription; dgReturnItems.Rows[i].Cells["clQtyIssued"].Value = dQtyAvaliableToReturn.ToString(); dgReturnItems.Rows[i].Cells["clQtyIssued"].Style.Alignment = DataGridViewContentAlignment.MiddleRight; dgReturnItems.Rows[i].Cells["clQtyRetuned"].Value = "0"; dgReturnItems.Rows[i].Cells["clQtyRetuned"].Style.Alignment = DataGridViewContentAlignment.MiddleRight; dgReturnItems.Rows[i].Cells["clCostPerUnit"].Value = sCostPerUnit; dgReturnItems.Rows[i].Cells["clItemUnit"].Value = sItemUnit; dgReturnItems.Rows[i].Cells["clItemType"].Value = sItemType; } oConn.Dispose(); }
private void LoadAsset(string sAssetNumber) { bool bLoaded = false; PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sConnStr); oConn.Open(); string sSql = "Select * from SOLAS where AssetNumber = '" + sAssetNumber + "'"; PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader(); while (rdReader.Read()) { txtAssetCode.Text = rdReader["AssetNumber"].ToString().Trim(); lblAssetCode.Text = rdReader["AssetNumber"].ToString().Trim(); txtAssetDescription.Text = rdReader["Description"].ToString().Trim(); lblAssetName.Text = rdReader["Description"].ToString().Trim(); bLoaded = true; } rdReader.Close(); oConn.Dispose(); if (bLoaded) { if (aGoodsLines.Length - 1 < 0) { GoodsIssueLine giNewLine = new GoodsIssueLine(); AddSalesLine(giNewLine); } } else { txtAssetCode.Text = ""; cmdSearchAsset_Click(null, null); } }
private void cmdSearchAsset_Click(object sender, EventArgs e) { Cursor = System.Windows.Forms.Cursors.WaitCursor; using (Solsage_Process_Management_System.Finder.AssetZoom frmAssetZoom = new Solsage_Process_Management_System.Finder.AssetZoom()) { if (frmAssetZoom.ShowDialog() == DialogResult.OK) { if (frmAssetZoom.sAssetNumber != "") { txtAssetCode.Text = frmAssetZoom.sAssetNumber; lblAssetCode.Text = frmAssetZoom.sAssetNumber; txtAssetDescription.Text = frmAssetZoom.sDescription; lblAssetName.Text = frmAssetZoom.sDescription; if (aGoodsLines.Length - 1 < 0) { GoodsIssueLine giNewLine = new GoodsIssueLine(); AddSalesLine(giNewLine); } } } } Cursor = System.Windows.Forms.Cursors.Default; }
public void InsertSalesLine(int iLineIndex, GoodsIssueLine giNewLine) { for (int iLines = 0; iLines < aGoodsLines.Length; iLines++) { GoodsIssueLine giThisline = aGoodsLines[iLines]; if (giThisline.iLineIndex == iLineIndex)//start line { Array.Resize<GoodsIssueLine>(ref aGoodsLines, aGoodsLines.Length + 1);//Add new row iLineRowIndex++; for (int iShiftLines = aGoodsLines.Length - 1; iShiftLines > iLines + 1; iShiftLines--) { aGoodsLines[iShiftLines] = aGoodsLines[iShiftLines - 1]; aGoodsLines[iShiftLines].Location = new Point(aGoodsLines[iShiftLines - 1].Location.X, aGoodsLines[iShiftLines - 1].Location.Y + 20); // move location of control to new position aGoodsLines[iShiftLines].iLineIndex++;//sync the lineindex of the control array } aGoodsLines[iLines + 1] = giNewLine; giNewLine.Top = 17 + ((iLineIndex + 1) * 20); giNewLine.Left = 4; if (giNewLine.txtStore.Text == "") { giNewLine.txtStore.Text = Global.sDefaultStore; } giNewLine.TabIndex = 50 + aGoodsLines.Length; giNewLine.TabStop = true; giNewLine.iLineIndex = iLines + 1; giNewLine.Name = "slNewLine_" + (aGoodsLines.Length - 1).ToString(); this.pnlDetails.Controls.Add(giNewLine); giNewLine.BringToFront(); return; } } }
public void focusNextLine(int iLineIndex) { if (iLineIndex >= aGoodsLines.Length && txtNumber.Text == "*NEW*") { GoodsIssueLine giNewline = new GoodsIssueLine(); AddSalesLine(giNewline); } GoodsIssueLine giNewLine = aGoodsLines[iLineIndex]; giNewLine.txtCode.Focus(); }
private void cmdCodeSearch_Click(object sender, EventArgs e) { Cursor = System.Windows.Forms.Cursors.WaitCursor; using (Finder.Inventory frmInventory = new Solsage_Process_Management_System.Finder.Inventory()) { //Sending "None" to inventory ShowDialog to identify that no workshop action should be taken if (frmInventory.ShowDialog(txtStore.Text,"","") == DialogResult.OK) { if (frmInventory.sResult != "") { //check if this item has been selected... if (((Documents.IssueInventory)(Parent.Parent.Parent.Parent)).CheckDuplicateSalesLine(frmInventory.sResult)) { MessageBox.Show("No duplicate items are allowed when issuing inventory. Please select another inventory item.", "Duplicates", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { txtCode.Text = frmInventory.sResult.Trim(); GoodsIssueLine giGoods = this; GoodsIssueLine giLastControl = this; if (frmInventory.bLinkItem && MessageBox.Show("This item is part of a KIT. Do you want to load all the items linked to this item? ", "Kit Item", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) //Kit Item { bNextLine = true; bool bContinue = Populate_Inventory_Fields(ref giGoods, false); txtCode.Focus(); txtCode.SelectionStart = 0; txtCode.SelectionLength = txtCode.Text.Length; if (bContinue) { PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr); oConn.Open(); string sSql = "select RMStore, ItemCode, RMQty, Remarks from LinkLines "; sSql += " where ItemCode <> '" + frmInventory.sResult + "' and LnkCode = '" + frmInventory.sResult + "'"; PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader(); while (rdReader.Read()) { GoodsIssueLine giKitLine = new GoodsIssueLine(); giKitLine.txtStore.Text = rdReader["RMStore"].ToString().Trim(); giKitLine.txtCode.Text = rdReader["ItemCode"].ToString().Trim(); if (giKitLine.txtCode.Text == "'") { giKitLine.txtDescription.Text = rdReader["Remarks"].ToString().Trim(); } //giKitLine.bDoCalculation = false; giKitLine.bNextLine = true; giKitLine.txtQuantity.Text = rdReader["RMQty"].ToString().Trim(); ((Documents.IssueInventory)(Parent.Parent.Parent.Parent)).InsertSalesLine(giLastControl.iLineIndex, giKitLine); giLastControl = giKitLine; //giKitLine.bDoCalculation = true; Populate_Inventory_Fields(ref giKitLine, false); } GoodsIssueLine slLastLine = (GoodsIssueLine)((Documents.IssueInventory)(Parent.Parent.Parent.Parent)).aGoodsLines[((Documents.IssueInventory)(Parent.Parent.Parent.Parent)).aGoodsLines.Length - 1]; if (slLastLine.txtCode.Text != "") { GoodsIssueLine slNewline = new GoodsIssueLine();//add empty line at the end ((Documents.IssueInventory)(Parent.Parent.Parent.Parent)).AddSalesLine(slNewline); } rdReader.Close(); oConn.Dispose(); //((Documents.IssueInventory)(Parent.Parent.Parent.Parent)).addTotals(); } } else { bool bValid = Populate_Inventory_Fields(ref giGoods, true); txtCode.Focus(); txtCode.SelectionStart = 0; txtCode.SelectionLength = txtCode.Text.Length; } } } } } Cursor = System.Windows.Forms.Cursors.Default; }
private bool Populate_Inventory_Fields(ref GoodsIssueLine giIssueLine, bool bFocusDescription) { bool bExist = false; if (giIssueLine.txtCode.Text == "'") { giIssueLine.txtExcPrice.ReadOnly = true; giIssueLine.txtQuantity.ReadOnly = true; giIssueLine.txtQuantity.Text = "0"; giIssueLine.txtUnit.ReadOnly = true; giIssueLine.txtStore.ReadOnly = true; giIssueLine.txtDescription.Focus(); return true; } else { using (PsqlConnection oConn = new PsqlConnection(Solsage_Process_Management_System.Classes.Connect.sPastelConnStr)) { oConn.Open(); string sSql = "SELECT distinct Inventory.*, CostThis01, CostThis02, CostThis03, CostThis04, CostThis05, CostThis06, "; sSql += " CostThis07, CostThis08, CostThis09, CostThis10, CostThis11, CostThis12, CostThis13, SellExcl01 "; sSql += " from Inventory "; sSql += " left join MultiStoreTrn on Inventory.ItemCode = MultiStoreTrn.ItemCode "; sSql += " where (MultiStoreTrn.StoreCode = '" + giIssueLine.txtStore.Text.Trim() + "')and (Inventory.ItemCode = '" + giIssueLine.txtCode.Text.Trim() + "')"; PsqlDataReader rdReader = Solsage_Process_Management_System.Classes.Connect.getDataCommand(sSql, oConn).ExecuteReader(); while (rdReader.Read()) { string sItemCost = ""; switch (Global.sCurrFinPeriod) { case "1": sItemCost = rdReader["CostThis01"].ToString(); break; case "2": sItemCost = rdReader["CostThis02"].ToString(); break; case "3": sItemCost = rdReader["CostThis03"].ToString(); break; case "4": sItemCost = rdReader["CostThis04"].ToString(); break; case "5": sItemCost = rdReader["CostThis05"].ToString(); break; case "6": sItemCost = rdReader["CostThis06"].ToString(); break; case "7": sItemCost = rdReader["CostThis07"].ToString(); break; case "8": sItemCost = rdReader["CostThis08"].ToString(); break; case "9": sItemCost = rdReader["CostThis09"].ToString(); break; case "10": sItemCost = rdReader["CostThis10"].ToString(); break; case "11": sItemCost = rdReader["CostThis11"].ToString(); break; case "12": sItemCost = rdReader["CostThis12"].ToString(); break; case "13": sItemCost = rdReader["CostThis13"].ToString(); break; } if (rdReader["Physical"].ToString().Trim() == "0") { sItemCost = rdReader["SellExcl01"].ToString().Trim(); } //check if inventory is available bExist = true; if (rdReader["UserDefText01"].ToString().Trim().ToUpper() == "ORDER" || rdReader["UserDefText01"].ToString().Trim().ToUpper() == "RESERVED" || rdReader["UserDefText01"].ToString().Trim().ToUpper() == "WORKSHOP") { //inventory is not available MessageBox.Show("Inventory is currently not available.\r\n\r\nStatus: " + rdReader["UserDefText01"].ToString().Trim(), "Item Not Available", MessageBoxButtons.OK, MessageBoxIcon.Warning); clearLine(); giIssueLine.txtCode.Focus(); giIssueLine.bNextLine = false; return false; } if (!bNextLine) { bNextLine = true; GoodsIssueLine giNewline = new GoodsIssueLine(); ((Documents.IssueInventory)(Parent.Parent.Parent.Parent)).AddSalesLine(giNewline); } string sInventoryGroup = rdReader["UserDefNum01"].ToString(); // 0 = Consumable; 1 = Lease Item; 2 = Returable Consumable if (sInventoryGroup == "1") { giIssueLine.txtItemType.Text = sInventoryGroup; //Asset } else if (sInventoryGroup == "0") { if (rdReader["Physical"].ToString().Trim() == "1") giIssueLine.txtItemType.Text = "0"; //Consumable else giIssueLine.txtItemType.Text = "2"; //Service Item } giIssueLine.txtDescription.Text = rdReader["Description"].ToString(); giIssueLine.txtUnit.Text = rdReader["UnitSize"].ToString(); try { giIssueLine.txtExcPrice.Text = Convert.ToDouble(sItemCost).ToString("N2"); } catch { giIssueLine.txtExcPrice.Text = "0.00"; } if (bFocusDescription) { giIssueLine.txtDescription.Focus(); } }//end while rdReader.Close(); oConn.Dispose(); if (!bExist) { MessageBox.Show("Code does not exist in selected store.", "Inventory Not Found", MessageBoxButtons.OK, MessageBoxIcon.Warning); clearLine(); return false; } return true; } } }