Ejemplo n.º 1
0
        public static TurnOverObject CustomerRowToObject(DataRow turnOvers)
        {
            TurnOverObject obj = new TurnOverObject();
            try
            {
                if (turnOvers != null)
                {
                    if (turnOvers.Table.Columns.Contains(TurnOverObject.TNR_ID))
                        obj.TnrID = RowFunctions.GetValueFromRowToInteger(turnOvers, TurnOverObject.TNR_ID, true, DataRowVersion.Current);

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.YEAR))
                        obj.Year = RowFunctions.GetValueFromRowToInteger(turnOvers, TurnOverObject.YEAR, false, DataRowVersion.Current);

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.MONTH))
                        obj.Month = RowFunctions.GetValueFromRowToInteger(turnOvers, TurnOverObject.MONTH, false, DataRowVersion.Current);

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.DATE))
                        obj.Date = RowFunctions.GetValueFromRowToString(turnOvers, TurnOverObject.DATE, true, DataRowVersion.Current);

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.VEHICLE))
                        obj.Vehicle = RowFunctions.GetValueFromRowToString(turnOvers, TurnOverObject.VEHICLE, true, DataRowVersion.Current);

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.TURNOVER))
                        obj.TurnOver = RowFunctions.GetValueFromRowToDecimal(turnOvers, TurnOverObject.TURNOVER, true, DataRowVersion.Current);
                    return obj;
                }
                obj = null;
            }
            catch (System.Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return obj;
        }
Ejemplo n.º 2
0
 public void Remove(TurnOverObject value)
 {
     try
     {
         List.Remove(value);
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 3
0
 public int Add(TurnOverObject value)
 {
     try
     {
         return(List.Add(value));
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 4
0
 // Called by TurnOverObject when it changes
 internal void TurnOverObjectChanged(TurnOverObject turnOver)
 {
     try
     {
         int index = List.IndexOf(turnOver);
         OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 5
0
 // Methods.
 object IBindingList.AddNew()
 {
     try
     {
         TurnOverObject turnOver = new TurnOverObject();
         List.Add(turnOver);
         return(turnOver);
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 6
0
 protected override void OnRemoveComplete(int index, object value)
 {
     try
     {
         TurnOverObject turnOver = (TurnOverObject)value;
         turnOver.Parent = this;
         OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 7
0
        public static TurnOverObject CustomerRowToObject(DataRow turnOvers)
        {
            TurnOverObject obj = new TurnOverObject();

            try
            {
                if (turnOvers != null)
                {
                    if (turnOvers.Table.Columns.Contains(TurnOverObject.TNR_ID))
                    {
                        obj.TnrID = RowFunctions.GetValueFromRowToInteger(turnOvers, TurnOverObject.TNR_ID, true, DataRowVersion.Current);
                    }

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.YEAR))
                    {
                        obj.Year = RowFunctions.GetValueFromRowToInteger(turnOvers, TurnOverObject.YEAR, false, DataRowVersion.Current);
                    }

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.MONTH))
                    {
                        obj.Month = RowFunctions.GetValueFromRowToInteger(turnOvers, TurnOverObject.MONTH, false, DataRowVersion.Current);
                    }

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.DATE))
                    {
                        obj.Date = RowFunctions.GetValueFromRowToString(turnOvers, TurnOverObject.DATE, true, DataRowVersion.Current);
                    }

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.VEHICLE))
                    {
                        obj.Vehicle = RowFunctions.GetValueFromRowToString(turnOvers, TurnOverObject.VEHICLE, true, DataRowVersion.Current);
                    }

                    if (turnOvers.Table.Columns.Contains(TurnOverObject.TURNOVER))
                    {
                        obj.TurnOver = RowFunctions.GetValueFromRowToDecimal(turnOvers, TurnOverObject.TURNOVER, true, DataRowVersion.Current);
                    }
                    return(obj);
                }
                obj = null;
            }
            catch (System.Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return(obj);
        }
Ejemplo n.º 8
0
        protected override void OnSetComplete(int index, object oldValue, object newValue)
        {
            try
            {
                if (oldValue != newValue)
                {
                    TurnOverObject oldTurnOver = (TurnOverObject)oldValue;
                    TurnOverObject newTurnOver = (TurnOverObject)newValue;
                    oldTurnOver.Parent = null;
                    newTurnOver.Parent = this;

                    OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
                }
            }
            catch (System.Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
        }
Ejemplo n.º 9
0
 // Called by TurnOverObject when it changes
 internal void TurnOverObjectChanged(TurnOverObject turnOver)
 {
     try
     {
         int index = List.IndexOf(turnOver);
         OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 10
0
 public void Remove(TurnOverObject value)
 {
     try
     {
         List.Remove(value);
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 11
0
 // Methods.
 object IBindingList.AddNew()
 {
     try
     {
         TurnOverObject turnOver = new TurnOverObject();
         List.Add(turnOver);
         return turnOver;
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 12
0
 public int Add(TurnOverObject value)
 {
     try
     {
         return List.Add(value);
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Ejemplo n.º 13
0
        public TurnOverObjectCollection AddZeroTurnOvers(TurnOverObjectCollection turnOvers)
        {
            try
            {
                TurnOverObjectCollection newTurnOvers = new TurnOverObjectCollection();
                TurnOverObject newTurnOver;
                Boolean firstRow = true;
                int previousYear = 0;
                int previousMonth = 0;
                int month = 0;
                int year = 0;
                foreach (TurnOverObject turnOver in turnOvers)
                {
                    if (firstRow == false)
                    {
                        //Check Add zero TurnOver row
                        if (turnOver.Month != previousMonth + 1)
                        {
                            if (previousMonth != 12)
                            {
                                month = previousMonth + 1;
                                year = previousYear;
                            }
                            else
                            {
                                if (turnOver.Month != 1)
                                {
                                    month = 1;
                                    year = previousYear + 1;
                                }
                                else
                                {
                                    month = 0;
                                    year = 0;
                                }
                            }
                        }
                        else
                        {
                            month = 0;
                            year = 0;
                        }

                        //Add Zero TurnOver row
                        if (year != 0 & month != 0)
                        {
                            int i = 0;
                            do
                            {

                                newTurnOver = new TurnOverObject();
                                newTurnOver.Month = month + i;
                                newTurnOver.Year = year;
                                newTurnOver.TnrID = turnOver.TnrID;
                                newTurnOver.Vehicle = turnOver.Vehicle;
                                newTurnOver.TurnOver = 0;
                                newTurnOvers.Add(newTurnOver);
                                i += 1;

                                if (month + i == 13)
                                {
                                    month = 1;
                                    year = year + 1;
                                    i = 0;
                                }
                            }
                            while (turnOver.Month != month + i);
                        }
                    }

                    //Add Normal Turnover
                    newTurnOver = new TurnOverObject();
                    newTurnOver.Month = turnOver.Month;
                    newTurnOver.Year = turnOver.Year;
                    newTurnOver.TnrID = turnOver.TnrID;
                    newTurnOver.Vehicle = turnOver.Vehicle;
                    newTurnOver.TurnOver = turnOver.TurnOver;
                    newTurnOver.Date = turnOver.Date;
                    newTurnOvers.Add(newTurnOver);

                    firstRow = false;
                    previousMonth = newTurnOver.Month;
                    previousYear = newTurnOver.Year;
                }

                return newTurnOvers;
            }
            catch (System.Exception exception1)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
            }
            return turnOvers;
        }