Ejemplo n.º 1
0
        public bool Valid()
        {
            errorProvider1.Clear();
            bool a = textBoxCode.Text == "" && !r_si.IsAutoNumber();
            bool b = employeeKryptonComboBox.SelectedItem == null;
            bool c = divisionKryptonComboBox.SelectedItem == null;
            bool d = currencyKryptonComboBox.SelectedItem == null;
            bool h = termofpaymentKryptonComboBox.SelectedItem == null;
            bool k = supplierkryptonComboBox.SelectedItem == null;
            bool e = false;
            bool f = m_si.ID > 0 ? false : r_si.IsCodeExist(textBoxCode.Text);

            if (a)
            {
                errorProvider1.SetError(textBoxCode, "Code Can not Empty");
            }
            if (b)
            {
                errorProvider1.SetError(employeeKryptonComboBox, "Employee Can not Empty");
            }
            if (c)
            {
                errorProvider1.SetError(divisionKryptonComboBox, "Division Can not Empty");
            }
            if (d)
            {
                errorProvider1.SetError(currencyKryptonComboBox, "Currency Can not Empty");
            }
            if (h)
            {
                errorProvider1.SetError(termofpaymentKryptonComboBox, "TOP Can not Empty");
            }
            if (k)
            {
                errorProvider1.SetError(supplierkryptonComboBox, "Customer Can not Empty");
            }
            if (f)
            {
                errorProvider1.SetError(textBoxCode, a ? "Code Can not Empty & Code already used" : "Code already used");
            }

            int j = 0;

            for (int i = 0; i < itemsDataGrid.Rows.Count; i++)
            {
                Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag;
                //  if (dataItemskryptonDataGridView[unitColumn.Index, i].Value == null)
                //      continue;
                // Unit u = (Unit)Utils.FindEntityInList(dataItemskryptonDataGridView[unitColumn.Index, i].Value.ToString(), m_units);
                if (p == null)
                {
                    continue;
                }
                if (itemsDataGrid[unitColumn.Index, i].Value == null)
                {
                    itemsDataGrid.Rows[i].ErrorText = "Please choose unit.";
                    e = true;
                }
                if (itemsDataGrid[warehouseColumn.Index, i].Value == null)
                {
                    itemsDataGrid.Rows[i].ErrorText = "Please choose warehouse.";
                    e = true;
                }
                double qty = Convert.ToDouble(itemsDataGrid[QtyColumn.Index, i].Value);
                if (qty == 0)
                {
                    itemsDataGrid.Rows[i].ErrorText = itemsDataGrid.Rows[i].ErrorText + " Quantity must not 0(zero)";
                    e = true;
                }
                j++;
            }

            bool g = j == 0;

            if (g)
            {
                errorProvider1.SetError(itemsDataGrid, "Items must at least 1(one)");
            }
            return(!a && !b && !c && !d && !e && !f && !g);
        }