예제 #1
0
 // return convert to peso rate
 public static double GetToPESORate(ExcoCalendar calendar, string currency)
 {
     if (0 == currency.CompareTo("CA"))
     {
         if (PESOtoCAD(calendar) > 0.00000001)
         {
             return(1.0 / PESOtoCAD(calendar));
         }
         else
         {
             return(0.0);
         }
     }
     else if (0 == currency.CompareTo("US"))
     {
         // Change from corporate rate to col govt rate from FY2017 forward
         if (PESOtoCAD(calendar) > 0.00000001 && calendar.GetFiscalYear() > 16)
         {
             //Console.WriteLine("FY: " + calendar.GetFiscalYear() + "__FM: " + calendar.GetFiscalMonth());
             //Console.WriteLine(PESOtoCAD(calendar));
             //Console.WriteLine(ColGovtPesoToCad(calendar));
             return(ColGovtPesoToCad(calendar));
         }
         else if (PESOtoCAD(calendar) > 0.00000001)
         {
             return(USDtoCAD(calendar) / PESOtoCAD(calendar));
         }
         else
         {
             return(0.0);
         }
     }
     else if (0 == currency.CompareTo("CP"))
     {
         return(1.0);
     }
     else
     {
         throw new Exception("Invalid currency " + currency);
     }
 }
예제 #2
0
        public double GetMonthlyBudget(ExcoCustomer customer, int plant, ExcoCalendar calendar)
        {
            double value = 0.0;

            try
            {
                if (1 == plant)
                {
                    ExcoODBC database = ExcoODBC.Instance;
                    database.Open(Database.DECADE_MARKHAM);
                    string         query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + " from tiger.dbo.Markham_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.BillToID + "'";
                    OdbcDataReader reader = database.RunQuery(query);
                    if (reader.Read())
                    {
                        value = Convert.ToDouble(reader[0]);
                        reader.Close();
                    }
                    else
                    {
                        reader.Close();
                        query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + "from tiger.dbo.Markham_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.ShipToID + "'";
                        reader = database.RunQuery(query);
                        if (reader.Read())
                        {
                            value = Convert.ToDouble(reader[0]);
                            reader.Close();
                        }
                        else
                        {
                            reader.Close();
                            query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + "from tiger.dbo.Markham_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.SillyID + "'";
                            reader = database.RunQuery(query);
                            if (reader.Read())
                            {
                                value = Convert.ToDouble(reader[0]);
                            }
                            reader.Close();
                        }
                    }
                }
                else if (3 == plant)
                {
                    ExcoODBC database = ExcoODBC.Instance;
                    database.Open(Database.DECADE_MARKHAM);
                    string         query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + " from tiger.dbo.Michigan_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.BillToID + "'";
                    OdbcDataReader reader = database.RunQuery(query);
                    if (reader.Read())
                    {
                        value = Convert.ToDouble(reader[0]);
                        reader.Close();
                    }
                    else
                    {
                        reader.Close();
                        query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + "from tiger.dbo.Michigan_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.ShipToID + "'";
                        reader = database.RunQuery(query);
                        if (reader.Read())
                        {
                            value = Convert.ToDouble(reader[0]);
                            reader.Close();
                        }
                        else
                        {
                            reader.Close();
                            query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + "from tiger.dbo.Michigan_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.SillyID + "'";
                            reader = database.RunQuery(query);
                            if (reader.Read())
                            {
                                value = Convert.ToDouble(reader[0]);
                            }
                            reader.Close();
                        }
                    }
                }
                else if (5 == plant)
                {
                    ExcoODBC database = ExcoODBC.Instance;
                    database.Open(Database.DECADE_MARKHAM);
                    string         query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + " from tiger.dbo.Texas_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.BillToID + "'";
                    OdbcDataReader reader = database.RunQuery(query);
                    if (reader.Read())
                    {
                        value = Convert.ToDouble(reader[0]);
                        reader.Close();
                    }
                    else
                    {
                        reader.Close();
                        query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + "from tiger.dbo.Texas_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.ShipToID + "'";
                        reader = database.RunQuery(query);
                        if (reader.Read())
                        {
                            value = Convert.ToDouble(reader[0]);
                            reader.Close();
                        }
                        else
                        {
                            reader.Close();
                            query  = "select Period" + calendar.GetFiscalMonth().ToString("D2") + "from tiger.dbo.Texas_Budget where Year=20" + calendar.GetFiscalYear().ToString("D2") + " and CustomerID='" + customer.SillyID + "'";
                            reader = database.RunQuery(query);
                            if (reader.Read())
                            {
                                value = Convert.ToDouble(reader[0]);
                            }
                            reader.Close();
                        }
                    }
                }
                else if (4 == plant)
                {
                    int year;
                    int period;
                    if (calendar.GetFiscalMonth() >= 10)
                    {
                        year   = calendar.GetFiscalYear() + 1;
                        period = calendar.GetFiscalMonth() - 9;
                    }
                    else
                    {
                        year   = calendar.GetFiscalYear();
                        period = calendar.GetFiscalMonth() + 3;
                    }
                    ExcoODBC database = ExcoODBC.Instance;
                    database.Open(Database.DECADE_MARKHAM);
                    string         query  = "select Period" + period.ToString("D2") + " from tiger.dbo.Colombia_Budget where Year=20" + year.ToString("D2") + " and CustomerID='" + customer.BillToID + "'";
                    OdbcDataReader reader = database.RunQuery(query);
                    if (reader.Read())
                    {
                        value = Convert.ToDouble(reader[0]);
                        reader.Close();
                    }
                    else
                    {
                        reader.Close();
                        query  = "select Period" + period.ToString("D2") + "from tiger.dbo.Colombia_Budget where Year=20" + year.ToString("D2") + " and CustomerID='" + customer.ShipToID + "'";
                        reader = database.RunQuery(query);
                        if (reader.Read())
                        {
                            value = Convert.ToDouble(reader[0]);
                            reader.Close();
                        }
                        else
                        {
                            reader.Close();
                            query  = "select Period" + period.ToString("D2") + "from tiger.dbo.Colombia_Budget where Year=20" + year.ToString("D2") + " and CustomerID='" + customer.SillyID + "'";
                            reader = database.RunQuery(query);
                            if (reader.Read())
                            {
                                value = Convert.ToDouble(reader[0]);
                            }
                            reader.Close();
                        }
                    }
                }
            }
            catch
            {
                return(0.0);
            }
            return(value);
        }