private void TableView_ValidateRow(object sender, DevExpress.Xpf.Grid.GridRowValidationEventArgs e)
        {
            DateTime startDate = ((Task)e.Row).StartDate;
            DateTime endDate   = ((Task)e.Row).EndDate;

            e.IsValid = startDate < endDate;
        }
Exemple #2
0
        private void tblView_ValidateRow(object sender, DevExpress.Xpf.Grid.GridRowValidationEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            if (grdPhieu.GetCellValue(e.RowHandle, colMasp) == null || grdPhieu.GetCellValue(e.RowHandle, colMasp).ToString() == "")
            {
                e.SetError("Bạn chưa nhập mã hàng hóa..");
                e.IsValid = false;
                return;
            }

            double dSL = 0;

            try{
                Double.TryParse(grdPhieu.GetCellValue(e.RowHandle, colSoLuong).ToString(), out dSL);
            }
            catch { }
            if (dSL <= 0)
            {
                e.SetError("Bạn chưa nhập đơn giá hàng hóa..");
                e.IsValid = false;
                return;
            }
        }
        void TableView_ValidateRow(object sender, DevExpress.Xpf.Grid.GridRowValidationEventArgs e)
        {
            TestTable row = e.Row as TestTable;

            if (row.HasValidationErrors)
            {
                e.IsValid      = false;
                e.ErrorContent = "Row cannot be commited.";
            }
        }
Exemple #4
0
 private void TableView_ValidateRow(object sender, DevExpress.Xpf.Grid.GridRowValidationEventArgs e)
 {
     if (e.Row == null)
     {
         return;
     }
     if (e.RowHandle == GridControl.NewItemRowHandle)
     {
         e.IsValid = ((Product)e.Row).ProductName != string.Empty;
     }
 }
Exemple #5
0
        /// <summary>
        /// Validates a grid row
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tableViewDetail_ValidateRow(object sender, DevExpress.Xpf.Grid.GridRowValidationEventArgs e)
        {
            WaterMeterViewModel vm  = this.DataContext as WaterMeterViewModel;
            WaterMeterReading   row = e.Row as WaterMeterReading;

            try
            {
                if (null != row)
                {
                    // Rule-1:  All required fields must contain data
                    string results = ValidationRules.IsWaterMeterReadingRowValid((WaterMeterReading)e.Row);
                    if (!String.IsNullOrEmpty(results))
                    {
                        e.IsValid      = false;
                        e.ErrorType    = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical;
                        e.ErrorContent = "The highlighted field cannot be blank";
                        e.SetError(e.ErrorContent);
                        return;
                    }
                    // Rule-2: Meter Reading must be greater than previous reading.
                    //if (row.ReadingDate <= vm.SelectedProperty.LastMeterEntry.ReadingDate ||
                    //    row.MeterReading <= vm.SelectedProperty.LastMeterEntry.MeterReading)
                    if (row.ReadingDate <= vm.SelectedProperty.ReadingDate ||
                        row.MeterReading <= vm.SelectedProperty.MeterReading)
                    {
                        e.IsValid      = false;
                        e.ErrorType    = DevExpress.XtraEditors.DXErrorProvider.ErrorType.Critical;
                        e.ErrorContent = "The highlighted field cannot be less then the previous reading";
                        e.SetError(e.ErrorContent);
                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Row Error: " + ex.Message);
            }
            finally
            {
                if (e.IsValid)
                {
                    //row.Consumption = vm.CalculateWaterConsumption();
                    //row.PropertyID = vm.SelectedProperty.PropertyID; // assign the PropertID since it's a FK
                }
                e.Handled = true;
            }
        }
        /// <summary>
        /// Validates a grid row
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void tableViewDetail_ValidateRow(object sender, DevExpress.Xpf.Grid.GridRowValidationEventArgs e)
        {
            GolfCart row = e.Row as GolfCart;

            try
            {
                if (null != row)
                {
                    // TO-DO: add validation rules
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Row Error: " + ex.Message);
            }
            finally
            {
                if (e.IsValid)
                {
                    // TO-DO:  ?
                }
                e.Handled = true;
            }
        }
        private void tblView_ValidateRow(object sender, DevExpress.Xpf.Grid.GridRowValidationEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }
            if (grdPhieuNhap.GetCellValue(e.RowHandle, colMasp) == null || grdPhieuNhap.GetCellValue(e.RowHandle, colMasp).ToString() == "")
            {
                e.SetError("Bạn chưa nhập mã hàng hóa..");
                e.IsValid = false;
                return;
            }

            double dDG = 0, dSL = 0;

            try
            {
                Double.TryParse(grdPhieuNhap.GetCellValue(e.RowHandle, colDonGia).ToString(), out dDG);
                Double.TryParse(grdPhieuNhap.GetCellValue(e.RowHandle, colSoLuong).ToString(), out dSL);
            }
            catch { }
            if (dDG <= 0)
            {
                e.SetError("Bạn chưa nhập đơn giá hàng hóa..");
                e.IsValid = false;
                return;
            }
            if (dSL <= 0)
            {
                e.SetError("Bạn chưa nhập đơn giá hàng hóa..");
                e.IsValid = false;
                return;
            }

            double dVAT = 0, dTTVAT = 0, dNguyente = 0, dNguyenteRow = 0, dTTVatRow = 0, dThanhtienRow = 0;

            try{
                Double.TryParse(grdPhieuNhap.GetCellValue(e.RowHandle, colvat).ToString(), out dVAT);
                dNguyente = Math.Round(dSL * dDG, 0, MidpointRounding.AwayFromZero);
                if (dVAT > 0)
                {
                    dTTVAT = Math.Round(dNguyente * dVAT / 100, 0, MidpointRounding.AwayFromZero);
                }

                Double.TryParse(grdPhieuNhap.GetCellValue(e.RowHandle, colnguyente).ToString(), out dNguyenteRow);
                Double.TryParse(grdPhieuNhap.GetCellValue(e.RowHandle, colttvat).ToString(), out dTTVatRow);
                Double.TryParse(grdPhieuNhap.GetCellValue(e.RowHandle, colThanhtien).ToString(), out dThanhtienRow);

                if (dNguyente != Math.Round(dNguyenteRow, 0, MidpointRounding.AwayFromZero))
                {
                    e.SetError("Số tiền nguyên tệ không đúng.");
                    e.IsValid = false;
                    return;
                }
                if (dTTVAT != Math.Round(dTTVatRow, 0, MidpointRounding.AwayFromZero))
                {
                    e.SetError("Số tiền (VAT) không đúng.");
                    e.IsValid = false;
                    return;
                }
                if ((dNguyente + dTTVAT) != Math.Round(dThanhtienRow, 0, MidpointRounding.AwayFromZero))
                {
                    e.SetError("Tổng thành tiền không đúng.");
                    e.IsValid = false;
                    return;
                }
            }
            catch { }
            //string productCode = ((System.Data.DataRowView)(e.Value)).Row.ItemArray[3].ToString();
        }