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 = "";
            }
        }
 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 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;
         }
     }
 }