Exemple #1
0
        private void btnRelease_Click(object sender, EventArgs e)
        {
            if (String.IsNullOrEmpty(cbHolderName.Text))
            {
                cbHolderName.Focus();
            }
            else if (cbBags.SelectedIndex == -1)
            {
                cbBags.Focus();
            }
            else if (String.IsNullOrEmpty(txtLocation.Text))
            {
                txtLocation.Focus();
            }
            else
            {
                if (dgvItems.RowCount < 1)
                {
                    MessageBox.Show(null, cbBags.Text + " is empty.", "Release bag", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    clearRelease();
                    return;
                }


                if (dgvItems.RowCount > 0)
                {
                    if (dgvItems.Rows[0].Cells[8].Value.ToString().Equals("OUT"))
                    {
                        MessageBox.Show(null, "Sorry, but the bag is currently OUT.", "Release bag", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        clearRelease();
                        return;
                    }
                }

                DialogResult result = MessageBox.Show(null, "Make sure to double check the items, because you cannot alter the records for security purposes.", "Release bag", MessageBoxButtons.OKCancel, MessageBoxIcon.Information, MessageBoxDefaultButton.Button2);
                if (result == DialogResult.Cancel)
                {
                    return;
                }

                String holderId = null;
                String bagId    = ((ComboBoxItem)cbBags.SelectedItem).HiddenValue;
                //Holders
                if (cbHolderName.SelectedIndex < 0)
                {
                    if (inventory.addHolders(cbHolderName.Text, "1"))
                    {
                        holderId = inventory.getLastHolderId();
                        cbHolderName.Items.Add(new ComboBoxItem(cbHolderName.Text, holderId));
                    }
                }
                else
                {
                    holderId = ((ComboBoxItem)cbHolderName.SelectedItem).HiddenValue;
                }


                if (techbag.insertTechBagInfo(holderId, bagId, txtLocation.Text, dtpFrom.Value.ToString("yyyy-MM-dd"), dtpTo.Value.ToString("yyyy-MM-dd")))
                {
                    String  infoId = techbag.getLastInfoId();
                    Boolean ok     = false;

                    foreach (DataGridViewRow row in dgvItems.Rows)
                    {
                        String itemId     = row.Cells[1].Value.ToString();
                        String propertyNo = row.Cells[2].Value.ToString();
                        String status     = row.Cells[8].Value.ToString();
                        String condition  = row.Cells[9].Value.ToString();
                        String qty        = row.Cells[3].Value.ToString();
                        String bagItemId  = row.Cells[0].Value.ToString();

                        if (techbag.insertTechBagLogs(bagItemId, "Release", infoId, itemId, propertyNo, condition, qty, ""))
                        {
                            ok = true;
                        }
                    }
                    if (ok)
                    {
                        MessageBox.Show(null, "Bag was successfully released.", "Release bag", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        loadTechbags();
                        clearRelease();
                    }
                }
            }
        }
Exemple #2
0
        private void btnAssign_Click(object sender, EventArgs e)
        {
            String dateReceived = null;
            String holderId     = null;
            String itemId       = null;


            if (dgvItems.RowCount < 0)
            {
                MessageBox.Show(null, "Please select an item.", "Select item", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                dgvItems.Focus();
                return;
            }
            else
            {
                int index = dgvItems.CurrentCell.RowIndex;
                itemId = dgvItems.Rows[index].Cells[0].Value.ToString();
            }

            if (cbStatus.SelectedIndex < 0)
            {
                cbStatus.Focus();
                cbStatus.SelectAll();
            }
            else if (String.IsNullOrEmpty(cbHolderName.Text))
            {
                cbHolderName.Focus();
            }
            else
            {
                DialogResult result = MessageBox.Show(null, "Are you sure you want to assign the item to " + cbHolderName.Text + "?", "Assign to person", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2);
                if (result == DialogResult.No)
                {
                    return;
                }

                if (switchRecieved.Value == false)
                {
                    dateReceived = "0000-00-00";
                }
                else
                {
                    dateReceived = dtpDateReceived.Value.ToString("yyyy-MM-dd");
                }

                //Holders
                if (cbHolderName.SelectedIndex < 0)
                {
                    String isEmployee = null;
                    if (rbEmployee.Checked == true)
                    {
                        isEmployee = "1";
                    }
                    else
                    {
                        isEmployee = "0";
                    }

                    if (inventory.addHolders(cbHolderName.Text, isEmployee))
                    {
                        holderId = inventory.getLastHolderId();
                        cbHolderName.Items.Add(new ComboBoxItem(cbHolderName.Text, holderId));
                        cbHolderName.SelectedIndex = cbHolderName.Items.Count - 1;
                    }
                }
                else
                {
                    holderId = ((ComboBoxItem)cbHolderName.SelectedItem).HiddenValue;
                }


                //Inventory
                String statusId = ((ComboBoxItem)cbStatus.SelectedItem).HiddenValue;
                if (inventory.insertInventory(propertyNo, statusId, holderId, dateReceived, txtRemarks.Text, itemId, "0"))
                {
                    MessageBox.Show(null, "Item was successfully assigned to " + cbHolderName.Text + ".", "Assign to person", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    loadInventory();
                    loadItems();
                    txtRemarks.Text            = String.Empty;
                    cbHolderName.SelectedIndex = -1;
                    cbHolderName.Text          = string.Empty;
                    pnlAssign.Visible          = false;
                }
            }
        }