예제 #1
0
 public static bool _setField(FieldPivot fieldPivot, PivotGridField pivotGridField)
 {
     if (_checkField(fieldPivot, pivotGridField))
     {
         pivotGridField.FieldName = fieldPivot.FieldName;
         pivotGridField.Caption = fieldPivot.Caption;
         pivotGridField.AreaIndex = fieldPivot.VisibleIndex;
         pivotGridField.Width = fieldPivot.Width;
         if (fieldPivot.TypeField == TypeField.NgayThang)
         {
             if (fieldPivot.FollowGroupField == FollowGroupField.Ngay)
                 pivotGridField.GroupInterval =
                     DevExpress.XtraPivotGrid.PivotGroupInterval.DateDay;
             else if (fieldPivot.FollowGroupField == FollowGroupField.Thang)
                 pivotGridField.GroupInterval =
                     DevExpress.XtraPivotGrid.PivotGroupInterval.DateMonth;
             else if (fieldPivot.FollowGroupField == FollowGroupField.Quy)
                 pivotGridField.GroupInterval =
                     DevExpress.XtraPivotGrid.PivotGroupInterval.DateQuarter;
             else if (fieldPivot.FollowGroupField == FollowGroupField.Nam)
                 pivotGridField.GroupInterval =
                     DevExpress.XtraPivotGrid.PivotGroupInterval.DateYear;
         }
         else if (fieldPivot.TypeField == TypeField.So)
         {
             pivotGridField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
             pivotGridField.CellFormat.FormatString = fieldPivot.FormatString;
             pivotGridField.ValueFormat.FormatString = fieldPivot.FormatString;
         }
         else if (fieldPivot.TypeField == TypeField.VND)
         {
             pivotGridField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
             pivotGridField.CellFormat.FormatString = "{0:###,##0}";
             pivotGridField.ValueFormat.FormatString = "{0:###,##0}";
         }
         else if (fieldPivot.TypeField == TypeField.USD)
         {
             pivotGridField.CellFormat.FormatType = DevExpress.Utils.FormatType.Numeric;
             pivotGridField.CellFormat.FormatString = "c";
             pivotGridField.ValueFormat.FormatString = "c";
         }
         return true;
     }
     else
     {
         return false;
     }
 }
예제 #2
0
 /// <summary>
 /// DUYVT: Kiểm tra ràng buộc về kiểu dữ liệu cho phép        
 /// _ RowField:     Text
 /// _ ColumnField:  Text, DateTime
 /// _ DataField:   Numeric
 /// </summary>
 /// <param name="fieldPivot"></param>
 /// <returns></returns>
 private static bool _checkField(FieldPivot fieldPivot, PivotGridField pivotGridField)
 {
     if (pivotGridField.Area == PivotArea.RowArea &&
         fieldPivot.TypeField == TypeField.VanBan)
     {
         return true;
     }
     else if (pivotGridField.Area == PivotArea.ColumnArea &&
         (fieldPivot.TypeField == TypeField.VanBan ||
         fieldPivot.TypeField == TypeField.NgayThang))
     {
         return true;
     }
     else if ((pivotGridField.Area == PivotArea.DataArea ||
         pivotGridField.Area == PivotArea.FilterArea) &&
         (fieldPivot.TypeField == TypeField.So ||
         fieldPivot.TypeField == TypeField.VND ||
         fieldPivot.TypeField == TypeField.USD))
     {
         return true;
     }
     else
         return false;
 }
예제 #3
0
 public static bool _set(PivotGridControl pivotGrid, FieldPivot[] fieldPivots, PivotArea pivotArea)
 {
     foreach (FieldPivot field in fieldPivots)
     {
         PivotGridField _field = new PivotGridField();
         _field.Area = pivotArea;
         if (!_setField(field, _field))
         {
             PLMessageBox.ShowErrorMessage(
                 (pivotArea == PivotArea.RowArea ? "Row" :
                 (pivotArea == PivotArea.ColumnArea ? "Column" : "Data")) +
                 "Field cấu hình không đúng.");
             return false;
         }
         pivotGrid.Fields.Add(_field);
     }
     return true;
 }