Exemplo n.º 1
0
        public Decimal GetAverageTurnOverMonthGreaterThanDateByCustomer(DateTime date, CustomerObject customer)
        {
            TurnOverObjectCollection turnOvers;
            Decimal turnOver = 0;
            try
            {
                if (customer == null)
                    turnOvers = new TurnOverDataService().GetByGreaterThanDate(date);
                else
                    turnOvers = new TurnOverDataService().GetByCustomerGreaterThanDate(customer, date);

                for (int i = 0; i < turnOvers.Count; i++)
                {
                    turnOver += turnOvers[i].TurnOver;
                }
                decimal months = Math.Round(Convert.ToDecimal(System.DateTime.Now.Subtract(date).TotalDays) / Convert.ToDecimal(30.5), 0);
                turnOver = turnOver / months;
            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return turnOver;
        }
Exemplo n.º 2
0
        public static CustomerObject CustomerRowToObject(DataRow customer)
        {
            CustomerObject obj = new CustomerObject();
            try
            {
                if (customer != null)
                {
                    if (RowFunctions.GetValueFromRowToGuid(customer, CustomerObject.CUS_ID, false, DataRowVersion.Current) != Guid.Empty)
                    {
                        obj.CusID = RowFunctions.GetValueFromRowToGuid(customer, CustomerObject.CUS_ID, true, DataRowVersion.Current);
                        obj.TasID = RowFunctions.GetValueFromRowToInteger(customer, CustomerObject.TAS_ID, true, DataRowVersion.Current);
                        obj.Name = RowFunctions.GetValueFromRowToString(customer, CustomerObject.NAME, true, DataRowVersion.Current);
                        obj.Name2 = RowFunctions.GetValueFromRowToString(customer, CustomerObject.NAME2, true, DataRowVersion.Current);
                        obj.Street = RowFunctions.GetValueFromRowToString(customer, CustomerObject.STREET, true, DataRowVersion.Current);
                        obj.HouseNumber = RowFunctions.GetValueFromRowToString(customer, CustomerObject.HOUSE_NUMBER, true, DataRowVersion.Current);
                        obj.Zipcode = RowFunctions.GetValueFromRowToString(customer, CustomerObject.ZIPCODE, true, DataRowVersion.Current);
                        obj.Town = RowFunctions.GetValueFromRowToString(customer, CustomerObject.TOWN, true, DataRowVersion.Current);
                        obj.Country = RowFunctions.GetValueFromRowToString(customer, CustomerObject.COUNTRY, true, DataRowVersion.Current);
                        obj.Vat = RowFunctions.GetValueFromRowToString(customer, CustomerObject.VAT, true, DataRowVersion.Current);
                        obj.Phone = RowFunctions.GetValueFromRowToString(customer, CustomerObject.PHONE, true, DataRowVersion.Current);
                        obj.Language = RowFunctions.GetValueFromRowToString(customer, CustomerObject.LANGUAGE, true, DataRowVersion.Current);
                        obj.Currency = RowFunctions.GetValueFromRowToString(customer, CustomerObject.CURRENCY, true, DataRowVersion.Current);
                    }

                    return obj;
                }
                obj = null;
            }
            catch (System.Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return obj;
        }
Exemplo n.º 3
0
 public void Remove(CustomerObject value)
 {
     try
     {
         List.Remove(value);
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 4
0
 public int Add(CustomerObject value)
 {
     try
     {
         return(List.Add(value));
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 5
0
 // Called by CustomerObject when it changes
 internal void CustomerObjectChanged(CustomerObject customer)
 {
     try
     {
         int index = List.IndexOf(customer);
         OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 6
0
 // Methods.
 object IBindingList.AddNew()
 {
     try
     {
         CustomerObject customer = new CustomerObject();
         List.Add(customer);
         return(customer);
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 7
0
 public Decimal GetAverageTurnOverMonthByYearByCustomer(int year, CustomerObject customer)
 {
     Decimal turnOver;
     try
     {
         turnOver = new TurnOverDataService().GetAverageTurnOverMonthByYearByCustomer(customer, year);
     }
     catch (System.Exception exception1)
     {
         System.Exception innerException = exception1;
         throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
     return turnOver;
 }
Exemplo n.º 8
0
 protected override void OnRemoveComplete(int index, object value)
 {
     try
     {
         CustomerObject customer = (CustomerObject)value;
         customer.Parent = this;
         OnListChanged(new ListChangedEventArgs(ListChangedType.ItemDeleted, index));
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 9
0
        public TurnOver(CustomerObject customer)
        {
            try
            {

                InitializeComponent();
                _blTurnover = new BL.External.TAS.TurnOver.TurnOver();
                _customer = customer;
                FillControls();
                AddSerie(1, System.DateTime.Now.Year);
            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
        }
Exemplo n.º 10
0
 public void Remove(CustomerObject customer)
 {
     try
     {
         CheckTransaction();
         new CustomerDataService(Transaction).Remove(customer);
         if (IsOwner) Transaction.Commit();
     }
     catch (Exception exception1)
     {
         if (IsOwner) Transaction.Rollback();
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
     finally
     {
         if (IsOwner) Connection.Close();
     }
 }
Exemplo n.º 11
0
        protected override void OnSetComplete(int index, object oldValue, object newValue)
        {
            try
            {
                if (oldValue != newValue)
                {
                    CustomerObject oldCustomer = (CustomerObject)oldValue;
                    CustomerObject newCustomer = (CustomerObject)newValue;
                    oldCustomer.Parent = null;
                    newCustomer.Parent = this;

                    OnListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index));
                }
            }
            catch (System.Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
        }
Exemplo n.º 12
0
 public Customer(PROF_IT.Common.Enumerations.TypeForm typeForm, CustomerObject customer)
 {
     try
     {
         InitializeComponent();
         _customer = customer;
         _typeForm = typeForm;
         if (_typeForm == PROF_IT.Common.Enumerations.TypeForm.NewForm)
         {
             throw new NotImplementedException();
         }
         else
         {
             InitializePropertyForm();
         }
     }
     catch (System.Exception exception1)
     {
         System.Exception innerException = exception1;
         throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 13
0
 public Customer(PROF_IT.Common.Enumerations.TypeForm typeForm, CustomerObject customer)
 {
     try
     {
         InitializeComponent();
         _customer = customer;
         _typeForm = typeForm;
         if (_typeForm == PROF_IT.Common.Enumerations.TypeForm.NewForm)
         {
             throw new NotImplementedException();
         }
         else
         {
             InitializePropertyForm();
         }
     }
     catch (System.Exception exception1)
     {
         System.Exception innerException = exception1;
         throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 14
0
        public static CustomerObject CustomerRowToObject(DataRow customer)
        {
            CustomerObject obj = new CustomerObject();

            try
            {
                if (customer != null)
                {
                    if (RowFunctions.GetValueFromRowToGuid(customer, CustomerObject.CUS_ID, false, DataRowVersion.Current) != Guid.Empty)
                    {
                        obj.CusID       = RowFunctions.GetValueFromRowToGuid(customer, CustomerObject.CUS_ID, true, DataRowVersion.Current);
                        obj.TasID       = RowFunctions.GetValueFromRowToInteger(customer, CustomerObject.TAS_ID, true, DataRowVersion.Current);
                        obj.Name        = RowFunctions.GetValueFromRowToString(customer, CustomerObject.NAME, true, DataRowVersion.Current);
                        obj.Name2       = RowFunctions.GetValueFromRowToString(customer, CustomerObject.NAME2, true, DataRowVersion.Current);
                        obj.Street      = RowFunctions.GetValueFromRowToString(customer, CustomerObject.STREET, true, DataRowVersion.Current);
                        obj.HouseNumber = RowFunctions.GetValueFromRowToString(customer, CustomerObject.HOUSE_NUMBER, true, DataRowVersion.Current);
                        obj.Zipcode     = RowFunctions.GetValueFromRowToString(customer, CustomerObject.ZIPCODE, true, DataRowVersion.Current);
                        obj.Town        = RowFunctions.GetValueFromRowToString(customer, CustomerObject.TOWN, true, DataRowVersion.Current);
                        obj.Country     = RowFunctions.GetValueFromRowToString(customer, CustomerObject.COUNTRY, true, DataRowVersion.Current);
                        obj.Vat         = RowFunctions.GetValueFromRowToString(customer, CustomerObject.VAT, true, DataRowVersion.Current);
                        obj.Phone       = RowFunctions.GetValueFromRowToString(customer, CustomerObject.PHONE, true, DataRowVersion.Current);
                        obj.Language    = RowFunctions.GetValueFromRowToString(customer, CustomerObject.LANGUAGE, true, DataRowVersion.Current);
                        obj.Currency    = RowFunctions.GetValueFromRowToString(customer, CustomerObject.CURRENCY, true, DataRowVersion.Current);
                    }

                    return(obj);
                }
                obj = null;
            }
            catch (System.Exception exception1)
            {
                Exception innerException = exception1;
                throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return(obj);
        }
Exemplo n.º 15
0
 public void Save(CustomerObject customer)
 {
     SqlCommand cmd = null;
     try
     {
         ExecuteNonQuery(out cmd, false, "Customer_SAVE",
             CreateParameter("@cusID", SqlDbType.UniqueIdentifier, customer.CusID, ParameterDirection.InputOutput),
             CreateParameter("@tasID", SqlDbType.Int, customer.TasID),
             CreateParameter("@Name", SqlDbType.NChar, customer.Name),
             CreateParameter("@Name2", SqlDbType.NChar, customer.Name2),
             CreateParameter("@Street", SqlDbType.NChar, customer.Street),
             CreateParameter("@HouseNumber", SqlDbType.NChar, customer.HouseNumber),
             CreateParameter("@Zipcode", SqlDbType.NChar, customer.Zipcode),
             CreateParameter("@Town", SqlDbType.NChar, customer.Town),
             CreateParameter("@Country", SqlDbType.NChar, customer.Country),
             CreateParameter("@VAT", SqlDbType.NChar, customer.Vat),
             CreateParameter("@Phone", SqlDbType.NChar, customer.Phone),
             CreateParameter("@Language", SqlDbType.NChar, customer.Language),
             CreateParameter("@Currency", SqlDbType.NChar, customer.Currency)
             );
         customer.CusID = (Guid)cmd.Parameters["cusID"].Value;
     }
     catch (Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
     finally
     {
         if (cmd != null)
         {
             cmd.Dispose();
         }
         cmd = null;
     }
 }
Exemplo n.º 16
0
 void IEditableObject.EndEdit()
 {
     try
     {
         if (inTxn)
         {
             _loadedTask = this.Task;
             _loadedEmployee = this.Employee;
             _loadedSupplier = this.Supplier;
             _loadedCustomer = this.Customer;
             _loadedUnknown = this.Unknown;
             _loadedAssignee = this.Assignee;
             _loadedReporter = this.Reporter;
             inTxn = false;
         }
     }
     catch (Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 17
0
 public Decimal GetAverageTurnOverMonthByYearByCustomer(CustomerObject customer, int year)
 {
     TurnOverObjectCollection turnOvers = new TurnOverObjectCollection();
     Decimal turnOver = new Decimal();
     try
     {
         if (customer == null) //Average All
             return GetAverageTurnOverMonthByYear(year);
         else // Average Customer
         {
             turnOvers = GetByCustomerByYear(customer, year);
             for (int i = 0; i < turnOvers.Count; i++)
             {
                 turnOver += turnOvers[i].TurnOver;
             }
             int months = 1;
             if (year != System.DateTime.Now.Year)
                 months = 12;
             else
                 months = System.DateTime.Now.Month;
             turnOver = turnOver / months;
         }
     }
     catch (System.Exception exception1)
     {
         throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
     }
     return turnOver;
 }
Exemplo n.º 18
0
        public Decimal GetTurnOverByYearByCustomer(CustomerObject customer, int year)
        {
            TurnOverObjectCollection turnOvers = new TurnOverObjectCollection();
            Decimal turnOver = new Decimal();
            SqlCommand cmd = null;
            DataTable dt;
            try
            {
                string query = "SELECT SUM(Turnover) "
                                + " FROM [TIS].[dbo].[TurnOverCustomer]"
                                + " WHERE tas_TNR_ID = " + customer.TasID + " AND Date >= '" + year + "0101' AND Date <= '" + year + "1231'";

                cmd = new SqlCommand(query);
                cmd.CommandType = CommandType.Text;
                cmd.Parameters.Add(new SqlParameter("@TNR_ID", customer.TasID));
                cmd.Parameters.Add(new SqlParameter("@YEAR", year));
                dt = this.ExecuteNonQuery(cmd, false).Tables[0];

                if (dt.Rows[0][0].ToString() == "")
                    turnOver = 0;
                else
                    turnOver = Convert.ToDecimal(dt.Rows[0][0].ToString());
            }
            catch (System.Exception exception1)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
            }
            return turnOver;
        }
Exemplo n.º 19
0
 public TurnOverObjectCollection GetByCustomerGreaterThanDate(CustomerObject customer, DateTime date)
 {
     TurnOverObjectCollection turnOvers = new TurnOverObjectCollection();
     SqlCommand cmd = null;
     try
     {
         cmd = new SqlCommand("TAS_TurnOver_ByCustomerGreaterThanDate");
         cmd.CommandType = CommandType.StoredProcedure;
         cmd.Parameters.Add(new SqlParameter("@TNR_ID", customer.TasID));
         cmd.Parameters.Add(new SqlParameter("@DATE", date));
         turnOvers = TurnOverConvertor.DataTableToCollection(this.ExecuteNonQuery(cmd, false).Tables[0]);
     }
     catch (System.Exception exception1)
     {
         throw new Exception(MethodBase.GetCurrentMethod().Name, exception1);
     }
     return AddZeroTurnOvers(turnOvers);
 }
Exemplo n.º 20
0
 public TurnOverObjectCollection GetByYear(int year, CustomerObject customer)
 {
     TurnOverObjectCollection turnOvers;
     try
     {
         if (customer == null)
             turnOvers = new TurnOverDataService().GetByYear(year);
         else
             turnOvers = new TurnOverDataService().GetByCustomerByYear(customer, year);
     }
     catch (System.Exception exception1)
     {
         System.Exception innerException = exception1;
         throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
     return turnOvers;
 }
Exemplo n.º 21
0
        public Decimal GetTurnOverByYearByCustomer(CustomerObject customer, int year)
        {
            Decimal turnOver = 0;
            try
            {
                if (customer != null)
                {
                    turnOver = new TurnOverDataService().GetTurnOverByYearByCustomer(customer, year);
                }

            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return turnOver;
        }
Exemplo n.º 22
0
 public TurnOverObjectCollection GetByCustomer(CustomerObject customer)
 {
     TurnOverObjectCollection turnOvers;
     try
     {
         turnOvers = new TurnOverDataService().GetByCustomer(customer);
     }
     catch (System.Exception exception1)
     {
         System.Exception innerException = exception1;
         throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
     return turnOvers;
 }
Exemplo n.º 23
0
        public TurnOverObjectCollection GetByCustomerGreaterThanDate(DateTime date, CustomerObject customer)
        {
            TurnOverObjectCollection turnOvers;
            try
            {
                if (customer == null)
                    turnOvers = new TurnOverDataService().GetByGreaterThanDate(date);
                else
                    turnOvers = new TurnOverDataService().GetByCustomerGreaterThanDate(customer, date);

            }
            catch (System.Exception exception1)
            {
                System.Exception innerException = exception1;
                throw new System.Exception(MethodBase.GetCurrentMethod().Name, innerException);
            }
            return turnOvers;
        }
Exemplo n.º 24
0
 public int Add(CustomerObject value)
 {
     try
     {
         return List.Add(value);
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 25
0
 // Methods.
 object IBindingList.AddNew()
 {
     try
     {
         CustomerObject customer = new CustomerObject();
         List.Add(customer);
         return customer;
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 26
0
 public bool Remove(CustomerObject customer)
 {
     SqlCommand cmd = null;
     try
     {
         ExecuteNonQuery(out cmd, false, "Customer_DELETE",
             CreateParameter("@cusID", SqlDbType.UniqueIdentifier, customer.CusID, ParameterDirection.Input)
             );
         return true;
     }
     catch (Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
     finally
     {
         if (cmd != null)
         {
             cmd.Dispose();
         }
         cmd = null;
     }
 }
Exemplo n.º 27
0
 public void Remove(CustomerObject value)
 {
     try
     {
         List.Remove(value);
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }
Exemplo n.º 28
0
 // Called by CustomerObject when it changes
 internal void CustomerObjectChanged(CustomerObject customer)
 {
     try
     {
         int index = List.IndexOf(customer);
         OnListChanged(new ListChangedEventArgs(ListChangedType.ItemChanged, index));
     }
     catch (System.Exception exception1)
     {
         Exception innerException = exception1;
         throw new Exception(MethodBase.GetCurrentMethod().Name, innerException);
     }
 }