Beispiel #1
0
 private void correctRecordsStatus(DataTable table)
 {
     for (int i = 0; i < table.Rows.Count; ++i)
     {
         DataRow row = table.Rows[i];
         if (row.RowState == DataRowState.Modified)
         {
             bool changed = false;
             for (int c = 0; c < table.Columns.Count; ++c)
             {
                 object cur = row[c];
                 object orj = row[c, DataRowVersion.Original];
                 if (!ToolType.isEqual(cur, orj))
                 {
                     changed = true;
                     break;
                 }
             }
             if (!changed)
             {
                 row.AcceptChanges();
             }
         }
     }
 }
Beispiel #2
0
 public static void set(DataRow row, DataColumn pCol, object pVal)
 {
     if ((row != null) && (pVal != null) && (pCol != null) && (row.RowState != DataRowState.Deleted))
     {
         object curVal = row[pCol];
         if (!ToolType.isEqual(curVal, pVal))
         {
             row[pCol] = pVal;
         }
     }
 }
Beispiel #3
0
                bool isChangedAfterFocusIn()
                {
                    object curr_ = readPropertyObject();

                    if (valueOnFocusIn == null && curr_ == null)
                    {
                        return(false);
                    }

                    return(!ToolType.isEqual(valueOnFocusIn, curr_));
                }
Beispiel #4
0
        protected virtual bool hasValidId(DataRow row, string col)
        {
            object defVal = ToolCell.getCellTypeDefaulValue(row.Table.Columns[col].DataType);
            object curId  = row[col];

            if (ToolCell.isNull(curId) || ToolType.isEqual(defVal, curId))
            {
                return(false);
            }
            return(true);
        }
Beispiel #5
0
        static object[] compareData(DataRow row, DataColumn[] cols, object[] values)
        {
            bool sameData = true;

            object[] curValues = ToolRow.copyRowToArr(cols, row);
            for (int i = 0; i < curValues.Length; ++i)
            {
                if (!ToolType.isEqual(curValues[i], values[i]))
                {
                    sameData = false;
                    break;
                }
            }
            return(sameData ? null : curValues);
        }
Beispiel #6
0
        public static DataRow search(DataTable pTable, string pCol, object pVal)
        {
            int colIndx = pTable.Columns.IndexOf(pCol);

            foreach (DataRow row in pTable.Rows)
            {
                if (row.RowState != DataRowState.Deleted)
                {
                    if (ToolType.isEqual(row[colIndx], pVal))
                    {
                        return(row);
                    }
                }
            }
            return(null);
        }
        public static double itemAmountInDoc(object lref, DataTable docLines)
        {
            double fix = 0;

            foreach (DataRow lRow in docLines.Rows)
            {
                if (lRow.RowState != DataRowState.Deleted)
                {
                    if (ToolType.isEqual(lref, lRow[TableSTLINE.STOCKREF]))
                    {
                        fix += getStockDocLineAmount(lRow);
                    }
                }
            }
            return(fix);
        }
Beispiel #8
0
        public static DataRow[] searchAll(DataTable pTable, string pCol, object pVal)
        {
            List <DataRow> list_   = new List <DataRow>();
            int            colIndx = pTable.Columns.IndexOf(pCol);

            foreach (DataRow row in pTable.Rows)
            {
                if (row.RowState != DataRowState.Deleted)
                {
                    if (ToolType.isEqual(row[colIndx], pVal))
                    {
                        list_.Add(row);
                    }
                }
            }
            return(list_.ToArray());
        }
Beispiel #9
0
        public void searchRecord(object obj)
        {
            if (obj == null)
            {
                return;
            }

            object recRef = null;

            if (recRef == null)
            {
                object val = obj as string;
                if (val != null)
                {
                    recRef = val;
                }
            }

            if (recRef == null)
            {
                DataRow val = obj as DataRow;
                if (val != null && val.RowState != DataRowState.Deleted)
                {
                    DataColumn col = val.Table.Columns[TableDUMMY.LOGICALREF];
                    recRef = col != null ? val[col] : null;
                }
            }


            if (recRef != null && getTable() != null)
            {
                DataColumn col = getTable().Columns[TableDUMMY.LOGICALREF];
                if (col != null)
                {
                    foreach (DataRowView v in getTable().DefaultView)
                    {
                        if (ToolType.isEqual(v.Row[col], recRef))
                        {
                            grid.ActiveRow = v.Row;
                            return;
                        }
                    }
                }
            }
        }
Beispiel #10
0
        public static DataRow search(DataTable pTable, string pCol, object pVal, string pCol2, object pVal2)
        {
            List <DataRow> list_    = new List <DataRow>();
            int            colIndx  = pTable.Columns.IndexOf(pCol);
            int            colIndx2 = pTable.Columns.IndexOf(pCol2);

            foreach (DataRow row in pTable.Rows)
            {
                if (row.RowState != DataRowState.Deleted)
                {
                    if (ToolType.isEqual(row[colIndx], pVal) && ToolType.isEqual(row[colIndx2], pVal2))
                    {
                        return(row);
                    }
                }
            }
            return(null);
        }
 void validated(object sender, EventArgs e)
 {
     foreach (Binding b in DataBindings)
     {
         if (typeof(DataTable).IsAssignableFrom(b.DataSource.GetType()) && b.IsBinding)
         {
             if (b.BindingManagerBase.Current != null && b.PropertyName == DSProperty)
             {
                 object dsVal   = ((DataRowView)b.BindingManagerBase.Current)[b.BindingMemberInfo.BindingField];
                 object thisVal = this.GetType().GetProperty(DSProperty).GetValue(this, null);
                 if (!ToolCell.isNull(thisVal))
                 {
                     if (!ToolType.isEqual(dsVal, thisVal))
                     {
                         b.WriteValue();
                         b.ReadValue();
                     }
                 }
                 b.BindingManagerBase.EndCurrentEdit();
             }
         }
     }
 }
Beispiel #12
0
 public static bool isCellTypeDefaulValue(Type type, object val)
 {
     return(ToolType.isEqual(val, getCellTypeDefaulValue(type)));
 }