private void btnAddToList_Click(object sender, EventArgs e) { if (txtAmount.Text == "" || !double.TryParse(txtAmount.Text, out _) || double.Parse(txtAmount.Text) <= 0) { lbWarning.Text = "Amount is not valid"; } else { OrderItems item = new OrderItems((int)cbbPartName.SelectedValue, cbbPartName.Text, XuLy.getRequirementBatch((int)cbbPartName.SelectedValue) == true ? cbbBatchNumber.Text : "", float.Parse(txtAmount.Text)); bool trung = false; for (int i = 0; i < list.Count; i++) { if ((int)cbbPartName.SelectedValue == list[i].PartID && ((XuLy.getRequirementBatch((int)cbbPartName.SelectedValue) && cbbBatchNumber.Text == list[i].BatchNumber) || !XuLy.getRequirementBatch((int)cbbPartName.SelectedValue))) { list[i].Amount += double.Parse(txtAmount.Text); trung = true; viewDGV(); dgvWarehouseManagement.ClearSelection(); dgvWarehouseManagement.Rows[i].Selected = true; break; } } if (!trung) { list.Add(item); viewDGV(); dgvWarehouseManagement.ClearSelection(); dgvWarehouseManagement.Rows[list.Count - 1].Selected = true; } txtAmount.Text = ""; lbWarning.Text = ""; } }
private void dgv1_CellContentClick(object sender, DataGridViewCellEventArgs e) { List <InventoryManagementView> list = Program.list; if (e.RowIndex >= 0) { if (dgv1.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewLinkCell) { DataGridViewLinkCell link = (DataGridViewLinkCell)dgv1.Rows[e.RowIndex].Cells[e.ColumnIndex]; if (link.Value.ToString() == "Remove") { DialogResult rs = MessageBox.Show("Are you sure?", "Warning", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (rs == DialogResult.Yes) { XuLy.RemoveInventoryManagement(list[e.RowIndex].OrderID, list[e.RowIndex].OrderItemsID); Program.list = XuLy.getInventoryManagementView(); Program.f.viewInventoryTable(Program.list); } } if (link.Value.ToString() == "Edit") { EditInventoryManagement edit = new EditInventoryManagement(); Program.oldEdit = list[e.RowIndex]; edit.Show(); } } } }
private void EditInventoryManagement_Load(object sender, EventArgs e) { XuLy.getTransactionTypes(cbbTransactionType); XuLy.getSuppliers(cbbSuppliers); XuLy.getWarehouses(cbbSourceWarehouse); XuLy.getWarehouses(cbbDestinationWarehouse); XuLy.getParts(cbbPartName); InventoryManagementView viewOld = Program.oldEdit; cbbTransactionType.SelectedValue = viewOld.TransactionTypeID; if (viewOld.TransactionTypeID == 1) { cbbSuppliers.SelectedValue = viewOld.SupplierID; cbbSourceWarehouse.Enabled = false; cbbSourceWarehouse.SelectedIndex = -1; } else { cbbSourceWarehouse.SelectedValue = viewOld.SourceWarehouseID; cbbSuppliers.Enabled = false; cbbSuppliers.SelectedIndex = -1; } cbbDestinationWarehouse.SelectedValue = viewOld.DestinationWarehouseID; cbbPartName.SelectedValue = viewOld.PartID; dtpDate.Value = viewOld.Date; txtAmount.Text = viewOld.Amount.ToString(); txtBatchNumber.Text = viewOld.BatchNumber; }
public void viewDGV(int WarehouseID, List <InventoryReport> list) { dgvInventoryReport.Rows.Clear(); dgvInventoryReport.ColumnCount = 4; dgvInventoryReport.Columns[0].HeaderText = "Part Name"; dgvInventoryReport.Columns[1].HeaderText = "Current Stock"; dgvInventoryReport.Columns[2].HeaderText = "Received Stock"; dgvInventoryReport.Columns[3].HeaderText = "Action"; for (int i = 0; i < list.Count; i++) { dgvInventoryReport.Rows.Add(); dgvInventoryReport.Rows[i].Cells[0].Value = list[i].PartName; dgvInventoryReport.Rows[i].Cells[1].Value = list[i].ReceivedStock - list[i].TranferredStock; dgvInventoryReport.Rows[i].Cells[2].Value = list[i].ReceivedStock; if (XuLy.getRequirementBatch(list[i].PartID)) { DataGridViewLinkCell Remove = new DataGridViewLinkCell(); Remove.Value = "View Batch Numbers"; dgvInventoryReport.Rows[i].Cells[3] = Remove; } } foreach (DataGridViewColumn column in dgvInventoryReport.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; } }
private void dgvInventoryReport_CellContentClick(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex >= 0) { if (dgvInventoryReport.Rows[e.RowIndex].Cells[e.ColumnIndex] is DataGridViewLinkCell) { DataGridViewLinkCell link = (DataGridViewLinkCell)dgvInventoryReport.Rows[e.RowIndex].Cells[e.ColumnIndex]; if (link.Value.ToString() == "View Batch Numbers") { List <BatchNumbers> listt = XuLy.getBatchNumberView((int)cbbWareHouse.SelectedValue, list[e.RowIndex].PartID); formViewBatchNumbers f = new formViewBatchNumbers(); f.dgv.Rows.Clear(); f.dgv.ColumnCount = 4; f.dgv.Columns[0].HeaderText = "Batch Number"; f.dgv.Columns[1].HeaderText = "Current Stock"; f.dgv.Columns[2].HeaderText = "Received Stock"; f.dgv.Columns[3].HeaderText = "Transferred Stock"; for (int i = 0; i < listt.Count; i++) { f.dgv.Rows.Add(); f.dgv.Rows[i].Cells[0].Value = listt[i].BatchNumber; f.dgv.Rows[i].Cells[1].Value = listt[i].ReceivedStock - listt[i].TranferredStock; f.dgv.Rows[i].Cells[2].Value = listt[i].ReceivedStock; f.dgv.Rows[i].Cells[3].Value = listt[i].TranferredStock; } f.lbWarehouse.Text = cbbWareHouse.Text; f.lbPart.Text = list[e.RowIndex].PartName; f.Visible = true; } } } }
private void cbbWareHouse_SelectedIndexChanged(object sender, EventArgs e) { if (radCurrentStock.Checked) { list = XuLy.getInventoryReportView((int)cbbWareHouse.SelectedValue); for (int i = 0; i < list.Count; i++) { if (list[i].ReceivedStock - list[i].TranferredStock <= 0) { list.RemoveAt(i); i--; } } viewDGV((int)cbbWareHouse.SelectedValue, list); } if (radReceivedStock.Checked) { list = XuLy.getInventoryReportView((int)cbbWareHouse.SelectedValue); viewDGV((int)cbbWareHouse.SelectedValue, list); } if (radOutOfStock.Checked) { list = XuLy.getInventoryReportView((int)cbbWareHouse.SelectedValue); for (int i = 0; i < list.Count; i++) { if (list[i].ReceivedStock - list[i].TranferredStock > 0) { list.RemoveAt(i); i--; } } viewDGV((int)cbbWareHouse.SelectedValue, list); } }
private void radReceivedStock_CheckedChanged(object sender, EventArgs e) { if (radReceivedStock.Checked) { list = XuLy.getInventoryReportView((int)cbbWareHouse.SelectedValue); viewDGV((int)cbbWareHouse.SelectedValue, list); } }
private void btnUpdate_Click(object sender, EventArgs e) { if (((int)cbbTransactionType.SelectedValue == 1 && cbbSuppliers.SelectedIndex == -1) || ((int)cbbTransactionType.SelectedValue == 2 && cbbSourceWarehouse.SelectedIndex == -1) || txtAmount.Text == "") { lbWarning.Text = "Please enter information!"; } else { if ((int)cbbTransactionType.SelectedValue == 2 && ((int)cbbSourceWarehouse.SelectedValue == (int)cbbDestinationWarehouse.SelectedValue)) { lbWarning.Text = "Source and the Destination Warehouses can't be the same"; } else { float R = XuLy.getReceivedAmount((int)cbbSourceWarehouse.SelectedValue, (int)cbbPartName.SelectedValue, txtBatchNumber.Text); float T = XuLy.getTransferredAmount((int)cbbSourceWarehouse.SelectedValue, (int)cbbPartName.SelectedValue, txtBatchNumber.Text); if (R - T - int.Parse(txtAmount.Text) + Program.oldEdit.Amount < 0) { MessageBox.Show("Max amount remain: " + (R - T), ""); } else { InventoryManagementView viewOld = Program.oldEdit; InventoryManagementView viewNew = new InventoryManagementView(); viewNew.TransactionTypeID = (int)cbbTransactionType.SelectedValue; if ((int)cbbTransactionType.SelectedValue == 1) { viewNew.SupplierID = (int)cbbSuppliers.SelectedValue; } else { viewNew.SourceWarehouseID = (int)cbbSourceWarehouse.SelectedValue; } viewNew.DestinationWarehouseID = (int)cbbDestinationWarehouse.SelectedValue; viewNew.PartID = (int)cbbPartName.SelectedValue; viewNew.Amount = int.Parse(txtAmount.Text); viewNew.Date = dtpDate.Value; viewNew.OrderID = viewOld.OrderID; viewNew.OrderItemsID = viewOld.OrderItemsID; XuLy.EditInventoryManagement(viewNew); this.Close(); Program.list = XuLy.getInventoryManagementView(); Program.f.viewInventoryTable(Program.list); Program.f.dgv1.ClearSelection(); for (int i = 0; i < Program.list.Count; i++) { if (Program.list[i].OrderItemsID == viewNew.OrderItemsID) { Program.f.dgv1.Rows[i].Selected = true; break; } } } } } }
private void formWarehouseManagement_Load(object sender, EventArgs e) { XuLy.getWarehouses(cbbSourceWarehouse); XuLy.getWarehouses(cbbDestinationWarehouse); XuLy.getPartByWarehouse((int)cbbSourceWarehouse.SelectedValue, cbbPartName); XuLy.getBatchNumberByPart((int)cbbPartName.SelectedValue, cbbBatchNumber); if (!XuLy.getRequirementBatch((int)cbbPartName.SelectedValue)) { cbbBatchNumber.Enabled = false; } }
private void cbbPartName_SelectedIndexChanged(object sender, EventArgs e) { if (!(cbbPartName.SelectedValue is System.Data.DataRowView)) { XuLy.getBatchNumberByPart((int)cbbPartName.SelectedValue, cbbBatchNumber); if (!XuLy.getRequirementBatch((int)cbbPartName.SelectedValue)) { cbbBatchNumber.Enabled = false; } else { cbbBatchNumber.Enabled = true; } } }
private void btnSubmit_Click(object sender, EventArgs e) { if (list.Count == 0) { lbWarning.Text = "Empty Part"; } else { XuLy.addPurchaseOrder(1, int.Parse(cbbSuppliers.SelectedValue.ToString()), int.Parse(cbbWarehouse.SelectedValue.ToString()), dtpDate.Value, list); form f = new form(); f.Show(); Program.list = XuLy.getInventoryManagementView(); Program.f.viewInventoryTable(Program.list); lbWarning.Text = ""; this.Close(); } }
private void btnSubmit_Click(object sender, EventArgs e) { if (list.Count == 0) { lbWarning.Text = "Empty Part"; } else { if ((int)cbbSourceWarehouse.SelectedValue == (int)cbbDestinationWarehouse.SelectedValue) { lbWarning.Text = "Source and the Destination Warehouses can't be the same"; } else { bool validAmount = true; for (int i = 0; i < list.Count; i++) { float R = XuLy.getReceivedAmount((int)cbbSourceWarehouse.SelectedValue, (int)cbbPartName.SelectedValue, cbbBatchNumber.Enabled == true ? cbbBatchNumber.SelectedValue.ToString() : ""); float T = XuLy.getTransferredAmount((int)cbbSourceWarehouse.SelectedValue, (int)cbbPartName.SelectedValue, cbbBatchNumber.Enabled == true ? cbbBatchNumber.SelectedValue.ToString() : ""); if (R - T - list[i].Amount < 0) { MessageBox.Show("Max amount of " + list[i].PartName + " [" + list[i].BatchNumber + "]" + ": " + (R - T), ""); validAmount = false; viewDGV(); dgvWarehouseManagement.ClearSelection(); dgvWarehouseManagement.Rows[i].Selected = true; break; } } if (!validAmount) { } else { XuLy.addWarehouseManagement(2, (int)cbbSourceWarehouse.SelectedValue, (int)cbbDestinationWarehouse.SelectedValue, dtpDate.Value, list); form f = new form(); f.Show(); Program.list = XuLy.getInventoryManagementView(); Program.f.viewInventoryTable(Program.list); lbWarning.Text = ""; this.Close(); } } } }
private void cbbSourceWarehouse_SelectedIndexChanged(object sender, EventArgs e) { if (!(cbbSourceWarehouse.SelectedValue is System.Data.DataRowView)) { XuLy.getPartByWarehouse((int)cbbSourceWarehouse.SelectedValue, cbbPartName); DialogResult rs; if (cbbSourceWarehouse.SelectedIndex != lastSelectedIndexSourceWarehouse && list.Count > 0) { rs = MessageBox.Show("Parts list will be clear\nAre you sure?", "Warning", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Warning); if (rs == DialogResult.Yes) { list.Clear(); viewDGV(); lastSelectedIndexSourceWarehouse = cbbSourceWarehouse.SelectedIndex; } else { cbbSourceWarehouse.SelectedIndex = lastSelectedIndexSourceWarehouse; } } } }
private void formPurchase_Order_Load(object sender, EventArgs e) { XuLy.getSuppliers(cbbSuppliers); XuLy.getWarehouses(cbbWarehouse); XuLy.getParts(cbbPartName); }
private void formPurchaseOrder_FormClosing(object sender, FormClosingEventArgs e) { Program.f.Show(); Program.list = XuLy.getInventoryManagementView(); Program.f.viewInventoryTable(Program.list); }
private void formInventoryReport_Load(object sender, EventArgs e) { XuLy.getWarehouses(cbbWareHouse); }
private void btnReload_Click(object sender, EventArgs e) { dgv1.ColumnCount = 0; Program.list = XuLy.getInventoryManagementView(); viewInventoryTable(Program.list); }
private void btnCancel_Click(object sender, EventArgs e) { this.Close(); Program.f.viewInventoryTable(XuLy.getInventoryManagementView()); }
private void form_Load(object sender, EventArgs e) { viewInventoryTable(XuLy.getInventoryManagementView()); }
private void formWarehouseManagement_FormClosing(object sender, FormClosingEventArgs e) { Program.f.Show(); Program.f.viewInventoryTable(XuLy.getInventoryManagementView()); }