Exemplo n.º 1
0
        public SummaryInvoice(ExcelWorksheet sheet, Dictionary <string, ColumnHeader> ch, int rownum)
        {
            RowNumber          = rownum;
            this.Customer      = new ColumnString(sheet, rownum, ch["Customer"]);
            this.InvoiceName   = new ColumnString(sheet, rownum, ch["Invoice"]);
            this.InvoiceDate   = new ColumnDateTime(sheet, rownum, ch["Invoice Date"]);
            this.InvoicePaid   = new ColumnDateTime(sheet, rownum, ch["Date Funds Recieved"]);
            this.HoursInvoiced = new ColumnInt(sheet, rownum, ch["Hours Invoiced"]);
            this.DaysInvoiced  = new ColumnDecimal(sheet, rownum, ch["Days Invoiced"]);
            this.InvoiceAmount = new ColumnDecimal(sheet, rownum, ch["Invoice Amount"]);
            this.TotalPaid     = new ColumnDecimal(sheet, rownum, ch["Total Paid"]);

            if (InvoiceDate.Value != null && InvoicePaid.Value != null)
            {
                DaysToPay       = new ColumnInt(sheet, rownum, ch["Days to pay"]);
                DaysToPay.Value = (int)((DateTime)InvoicePaid.Value - (DateTime)InvoiceDate.Value).TotalDays;
            }
            if (DaysInvoiced.Value != 0 && InvoiceAmount.Value != 0)
            {
                DayRate       = new ColumnDecimal(sheet, rownum, ch["Day Rate"]);
                DayRate.Value = InvoiceAmount.Value / DaysInvoiced.Value;
            }
            ExcelAddress invoiceRange = new ExcelAddress(rownum, InvoiceName.ColumnNumber, rownum, InvoiceName.ColumnNumber);

            if (sheet.Cells[invoiceRange.Address].Hyperlink != null)
            {
                this.InvoiceNameHyperLink = sheet.Cells[invoiceRange.Address].Hyperlink;
            }
        }
Exemplo n.º 2
0
        public static void UpdateCellInt(ExcelWorksheet sheet, int rownumber, ColumnInt field)
        {
            if (field == null || field?.Value == null && !field.Errors.Any())
            {
                return;
            }
            if (field.Value != null)
            {
                sheet.Cells[rownumber, field.ColumnNumber].Value = (int)field.Value;
            }

            WriteErrors(sheet, rownumber, field.ColumnNumber, field.Errors);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            Database db = new Database("test-db");

            List <Column> columns = new List <Column>();
            Column        ages    = new ColumnInt("Age");

            ages.AddValue("23");
            ages.AddValue("42");
            columns.Add(ages);
            Column names = new ColumnString("Name");

            names.AddValue("Maria");
            names.AddValue("Ignacio");
            columns.Add(names);
            db.CreateTable("People", columns);
            //string query = "SELECT * FROM People WHERE Age < 30;";
            //Console.WriteLine(query + ": " + db.RunQuery(query));

            string queryDelete = "DROP TABLE People;";

            Console.WriteLine(queryDelete + ": " + db.RunQuery(queryDelete));

            //string query = "SELECT Name FROM People;";
            //Console.WriteLine(query + ": " + db.RunQuery(query));

            //Console.WriteLine("MiniSQLJinix V0.0.0.0.0.1");

            //BDData db = BDData.getInstance();

            //int counter = 0;
            //string line;

            //// Read the file and display it line by line.
            //System.IO.StreamReader file =
            //    new System.IO.StreamReader(@"..\..\..\Prueba.txt");
            //while ((line = file.ReadLine()) != null)
            //{
            //    System.Console.WriteLine(line);
            //    counter++;
            //    string result = db.RunQuery(line);
            //    Console.WriteLine(result);
            //}

            //file.Close();
            //System.Console.WriteLine("There were {0} lines.", counter);
            //// Suspend the screen.
            //System.Console.ReadLine();
        }
Exemplo n.º 4
0
    public override String Run(Database bd)
    {
        //TODO: Create columns one by one in a list and call bd.CreateDatabase
        if (bd.GetTableByName(pTabla) != null)
        {
            return(Messages.TableErrorAlreadyExists);
        }
        if (pTipoDato.Count != columnNames.Count)
        {
            return(Messages.WrongSyntax + ", Ammount of column names provided and column types does not match.");
        }
        int           cont           = 0;
        List <Column> listOfCreation = new List <Column>();

        foreach (String tipo in pTipoDato)
        {
            Column column;
            if (String.IsNullOrWhiteSpace(columnNames[cont]) && String.IsNullOrEmpty(columnNames[cont]))
            {
                return(Messages.WrongSyntax + "; Empty, null or whitespace Strings are not accepted as column names.");
            }
            if (String.Equals(tipo, "TEXT", StringComparison.OrdinalIgnoreCase))
            {
                column = new ColumnString(columnNames[cont]);
            }
            else if (String.Equals(tipo, "INT", StringComparison.OrdinalIgnoreCase))
            {
                column = new ColumnInt(columnNames[cont]);
            }
            else if (String.Equals(tipo, "DOUBLE", StringComparison.OrdinalIgnoreCase))
            {
                column = new ColumnFloat(columnNames[cont]);
            }
            else
            {
                return(Messages.WrongSyntax + ", given type is not recognized by our system, please introduce the type in the form of 'String', 'Int' or 'Double' (System will ignore letter case)");
            }
            Console.WriteLine("Column created, type: " + tipo + ", column name: " + columnNames[cont]);
            listOfCreation.Add(column);
            cont++;
        }
        bd.CreateTable(pTabla, listOfCreation);
        return("CREATE TABLE Query was successful, on standby for Database CreateTable method to validate");
    }