private void gridViewMaster_CustomSummaryExists(object sender, DevExpress.Data.CustomSummaryExistEventArgs e) { if (e.IsTotalSummary && e.Item is GridColumnSummaryItem) { GridColumnSummaryItem item = e.Item as DevExpress.XtraGrid.GridColumnSummaryItem; try { HelpGridExt.SetFontFooter(gridViewMaster, new string[] { item.FieldName }, Color.Blue, Color.Empty, FontStyle.Bold); if (gridControlMaster.DataSource != null) { DataTable dt = (gridControlMaster.DataSource as DataTable).Copy(); if (dt.Columns.Contains(item.FieldName)) { GridColumn col = gridViewMaster.Columns[item.FieldName]; string filter = item.FieldName + " IS NOT NULL and convert(" + item.FieldName + ", 'System.String') <> '' "; if (gridViewMaster.ActiveFilterString != "") filter += " AND (" + gridViewMaster.ActiveFilterString + ")"; dt.DefaultView.RowFilter = filter; DataTable dtC = dt.DefaultView.ToTable(true, item.FieldName); DataTable dtA = dt.DefaultView.ToTable(false, item.FieldName); switch (item.SummaryType) { case DevExpress.Data.SummaryItemType.Count: item.DisplayFormat = string.Format("TỔNG SỐ [{0}]={1}", col.Caption, dtC.Rows.Count); break; case DevExpress.Data.SummaryItemType.Sum: if (item.FieldName == BIEN_MUC.THOI_LUONG) { long totalFrame = 0; TimeCode t; foreach (DataRow row in dtA.Rows) { t = new TimeCode(row[BIEN_MUC.THOI_LUONG].ToString()); totalFrame += (long)t.TotalFrame; } t = new TimeCode(totalFrame); item.DisplayFormat = string.Format("TỔNG CỘNG [{0}]={1}", col.Caption, t.TimeCodeString); } else item.DisplayFormat = "TỔNG CỘNG [" + col.Caption + "]={0}"; break; case DevExpress.Data.SummaryItemType.Average: string value; if (item.FieldName == BIEN_MUC.THOI_LUONG) { long totalFrame = 0; TimeCode t; foreach (DataRow row in dtA.Rows) { t = new TimeCode(row[BIEN_MUC.THOI_LUONG].ToString()); totalFrame += (long)t.TotalFrame; } if (dtA.Rows.Count > 0) { long av = totalFrame / dtA.Rows.Count; t = new TimeCode(av); value = t.TimeCodeString; } value = ""; } else { object obj = dtA.Compute("Avg(" + item.FieldName + ")", ""); value = HelpNumber.ParseDecimal(obj).ToString(); } item.DisplayFormat = string.Format("TRUNG BÌNH [{0}]={1}", col.Caption, value); break; case DevExpress.Data.SummaryItemType.Min: object min = dtC.Compute("Min(" + item.FieldName + ")", ""); item.DisplayFormat = string.Format("NHỎ NHẤT [{0}]={1}", col.Caption, min); break; case DevExpress.Data.SummaryItemType.Max: object max = dtC.Compute("Max(" + item.FieldName + ")", ""); item.DisplayFormat = string.Format("LỚN NHẤT [{0}]={1}", col.Caption, max); break; } foreach (GridColumn column in gridViewMaster.Columns) { if (column.Visible == false) continue; if (column.SummaryItem.SummaryType == DevExpress.Data.SummaryItemType.None) continue; column.Resize(column.GetBestWidth() + column.SummaryItem.DisplayFormat.Length); } return; } } item.SummaryType = DevExpress.Data.SummaryItemType.None; } catch { item.SummaryType = DevExpress.Data.SummaryItemType.None; } } }
public static void InitCotTimecode(GridColumn colunm, string fieldName, string fieldNameNum) { InitCotTimecode(colunm, fieldName); colunm.View.CellValueChanged += delegate(object sender, CellValueChangedEventArgs e) { var grid = sender as GridView; if (e.Column.FieldName == fieldName) { DataRow r = grid.GetDataRow(e.RowHandle); if (r == null) return; var tcTL = new TimeCode(r[fieldName].ToString()); r[fieldNameNum] = tcTL.TotalFrame; } }; }
public static TimeCode ParseToTimeCode(string timeCodeString) { var t = new TimeCode(timeCodeString); return t; }
public static TimeCode operator -(TimeCode timeCodeA, TimeCode timeCodeB) { TimeCode result = new TimeCode(HelpNumber.ParseInt64(Math.Abs(timeCodeA.TotalFrame - timeCodeB.TotalFrame))); if (timeCodeA.TotalFrame < timeCodeB.TotalFrame) { result.Hour = -result.Hour; } return result; }
public static decimal ParesToTotalFrame(string timeCodeString) { var t = new TimeCode(timeCodeString); return t.TotalFrame; }