예제 #1
0
        private void buttonSpecAny1_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                gridData.Rows.Clear();

                IList records = r_po.FindPObyPartAndPONo(searchText.Text.Trim(), m_listAdded, m_supplierID.ID, m_trdate);
                loadResult(records);
                this.Cursor = Cursors.Default;
            }
            catch (Exception x)
            {
                KryptonMessageBox.Show(x.Message, "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            finally
            {
                this.Cursor = Cursors.Default;
            }
        }
예제 #2
0
        void dataItemskryptonDataGridView_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (m_editMode == EditMode.View)
            {
                return;
            }
            itemsDataGrid.Rows[e.RowIndex].ErrorText = "";
            if (!itemsDataGrid[e.ColumnIndex, e.RowIndex].IsInEditMode)
            {
                return;
            }

            if (e.ColumnIndex == scanColumn.Index)
            {
                if (e.FormattedValue.ToString() == "")
                {
                    return;
                }

                IList addedPI = new ArrayList();
                for (int i = 0; i < itemsDataGrid.Rows.Count; i++)
                {
                    if (i == e.RowIndex)
                    {
                        continue;
                    }
                    PurchaseOrderItem pi = (PurchaseOrderItem)itemsDataGrid[scanColumn.Index, i].Tag;
                    if (pi == null)
                    {
                        continue;
                    }
                    addedPI.Add(pi.ID);
                }
                IList res = r_po.FindPObyPartAndPONo(e.FormattedValue.ToString(), addedPI, ((Supplier)supplierkryptonComboBox.SelectedItem).ID, dateKryptonDateTimePicker.Value);
                if (res.Count == 0)
                {
                    using (SearchPOForGRNForm fr = new SearchPOForGRNForm(e.FormattedValue.ToString(), ((Supplier)supplierkryptonComboBox.SelectedItem), addedPI, m_mainForm.CurrentUser, dateKryptonDateTimePicker.Value))
                    {
                        fr.ShowDialog();
                        IList result = fr.RESULT;
                        m_poItems = result;
                    }
                }
                else
                {
                    m_poItems = res;
                }
            }
            if (QtyColumn.Index == e.ColumnIndex)
            {
                PurchaseOrderItem pi = (PurchaseOrderItem)itemsDataGrid[scanColumn.Index, e.RowIndex].Tag;
                if (pi == null)
                {
                    return;
                }
                Part p = (Part)itemsDataGrid[codeColumn.Index, e.RowIndex].Tag;
                if (p == null)
                {
                    return;
                }
                Unit u = (Unit)Utils.FindEntityInList(itemsDataGrid[unitColumn.Index, e.RowIndex].Value.ToString(), m_units);
                if (u == null)
                {
                    return;
                }
                p.UNIT_CONVERSION_LIST = r_part.GetUnitConversions(p.ID);
                GoodReceiveNoteItem sample = new GoodReceiveNoteItem();
                sample.PART      = p;
                sample.UNIT      = u;
                sample.QYTAMOUNT = Convert.ToDouble(e.FormattedValue);
                double qty  = sample.GetAmountInSmallestUnit();
                double rest = r_po.GetOutstandingReceived(pi.ID) - qty;
                if (rest < 0)
                {
                    e.Cancel = true;
                    itemsDataGrid.Rows[e.RowIndex].ErrorText = "Quantity exceed outstanding quantity";
                }
                //itemsDataGrid[OutstandingPOColumn.Index, e.RowIndex].Value = rest;
            }
            if (unitColumn.Index == e.ColumnIndex)
            {
                PurchaseOrderItem pi = (PurchaseOrderItem)itemsDataGrid[scanColumn.Index, e.RowIndex].Tag;
                if (pi == null)
                {
                    return;
                }
                Part p = (Part)itemsDataGrid[codeColumn.Index, e.RowIndex].Tag;
                if (p == null)
                {
                    return;
                }
                Unit u = (Unit)Utils.FindEntityInList(e.FormattedValue.ToString(), m_units);
                if (u == null)
                {
                    return;
                }
                p.UNIT_CONVERSION_LIST = r_part.GetUnitConversions(p.ID);
                GoodReceiveNoteItem sample = new GoodReceiveNoteItem();
                sample.PART      = p;
                sample.UNIT      = u;
                sample.QYTAMOUNT = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, e.RowIndex].Value);
                double qty  = sample.GetAmountInSmallestUnit();
                double rest = r_po.GetOutstandingReceived(pi.ID) - qty;
                if (rest < 0)
                {
                    e.Cancel = true;
                    itemsDataGrid.Rows[e.RowIndex].ErrorText = "Quantity exceed outstanding quantity";
                }
                //itemsDataGrid[OutstandingPOColumn.Index, e.RowIndex].Value = rest;
            }
        }