예제 #1
0
        public bool Valid()
        {
            errorProvider1.Clear();
            bool a = textBoxCode.Text == "" && !r_grn.IsAutoNumber();
            bool b = employeeKryptonComboBox.SelectedItem == null;
            bool k = supplierkryptonComboBox.SelectedItem == null;
            bool e = false;
            bool f = m_do.ID > 0 ? false : r_grn.IsCodeExist(textBoxCode.Text);

            if (a)
            {
                errorProvider1.SetError(textBoxCode, "Code Can not Empty");
            }
            if (b)
            {
                errorProvider1.SetError(employeeKryptonComboBox, "Employee 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++)
            {
                SalesOrderItem pi = (SalesOrderItem)itemsDataGrid[scanColumn.Index, i].Tag;
                if (pi == null)
                {
                    continue;
                }
                Part p = (Part)itemsDataGrid[codeColumn.Index, i].Tag;
                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 && !e && !f && !g);
        }