Пример #1
0
        private void buttonSpecAny1_Click(object sender, EventArgs e)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                gridData.Rows.Clear();

                IList records = r_po.FindPObyPartAndGRNNo(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;
                    }
                    GoodReceiveNoteItem pi = (GoodReceiveNoteItem)itemsDataGrid[scanColumn.Index, i].Tag;
                    if (pi == null)
                    {
                        continue;
                    }
                    addedPI.Add(pi.ID);
                }
                IList res = r_grn.FindPObyPartAndGRNNo(e.FormattedValue.ToString(), addedPI, ((Supplier)supplierkryptonComboBox.SelectedItem).ID, dateKryptonDateTimePicker.Value);
                if (res.Count == 0)
                {
                    using (SearchGRNForPRForm fr = new SearchGRNForPRForm(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)
            {
                GoodReceiveNoteItem pi = (GoodReceiveNoteItem)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);
                PurchaseReturnItem sample = new PurchaseReturnItem();
                sample.PART      = p;
                sample.UNIT      = u;
                sample.QYTAMOUNT = Convert.ToDouble(e.FormattedValue);
                double qty  = sample.GetAmountInSmallestUnit();
                double rest = r_grn.GetOutstandingReturned(pi.ID) - qty;
                if (rest < 0)
                {
                    e.Cancel = true;
                    itemsDataGrid.Rows[e.RowIndex].ErrorText = "Quantity exceed outstanding quantity";
                }
                // itemsDataGrid[OutstandingPOColumn.Index, e.RowIndex].Value = r_grn.GetOutstandingReturned(pi.ID);
            }
            if (unitColumn.Index == e.ColumnIndex)
            {
                GoodReceiveNoteItem pi = (GoodReceiveNoteItem)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_grn.GetOutstandingReturned(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;
            }
        }