Ejemplo n.º 1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                FuelMember.Employee            = cmbEmployee.Text;
                FuelMember.FuelType            = (Framework.Common.Enumeration.Fuel.FuelType)Enum.Parse(typeof(Framework.Common.Enumeration.Fuel.FuelType), cmbFuelType.Text);
                FuelMember.Supplier            = cmbSupplier.Text;
                FuelMember.VehicleLicensePlate = cmbVehicle.Text;

                FuelMember.Date            = dteDate.DateTime;
                FuelMember.InvoiceOK       = cbxInvoiceOK.Checked;
                FuelMember.InvoiceReceived = cbxInvoiceReceived.Checked;
                FuelMember.PrivateTanking  = cbxPrivate.Checked;

                FuelMember.UnityPrice = calcUnityPrice.Value;
                FuelMember.Quantity   = calcQuantity.Value;
                FuelMember.TotalPrice = calcQuantity.Value * calcUnityPrice.Value;

                TIS.BL.Internal.Fuel fuelBL = new BL.Internal.Fuel();
                fuelBL.Save(FuelMember);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (System.Exception exception1)
            {
                System.Exception thisException = exception1;
                Management.ShowException(thisException);
            }
        }
Ejemplo n.º 2
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                FuelMember.Employee = cmbEmployee.Text;
                FuelMember.FuelType = (Framework.Common.Enumeration.Fuel.FuelType)Enum.Parse(typeof(Framework.Common.Enumeration.Fuel.FuelType), cmbFuelType.Text);
                FuelMember.Supplier = cmbSupplier.Text;
                FuelMember.VehicleLicensePlate = cmbVehicle.Text;

                FuelMember.Date = dteDate.DateTime;
                FuelMember.InvoiceOK = cbxInvoiceOK.Checked;
                FuelMember.InvoiceReceived = cbxInvoiceReceived.Checked;
                FuelMember.PrivateTanking = cbxPrivate.Checked;

                FuelMember.UnityPrice = calcUnityPrice.Value;
                FuelMember.Quantity = calcQuantity.Value;
                FuelMember.TotalPrice = calcQuantity.Value * calcUnityPrice.Value;

                TIS.BL.Internal.Fuel fuelBL = new BL.Internal.Fuel();
                fuelBL.Save(FuelMember);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch (System.Exception exception1)
            {
                System.Exception thisException = exception1;
                Management.ShowException(thisException);
            }
        }
Ejemplo n.º 3
0
        private void btnImportTotal_Click(object sender, EventArgs e)
        {
            try
            {

                try
                {
                    OpenFileDialog ofdImport = new OpenFileDialog();
                    ofdImport.Title = "Select file";
                    ofdImport.Filter = "Excel Sheet(*.xlsx)|*.xlsx|Excel Sheet 2003(*.xls)|*.xls|All Files(*.*)|*.*";
                    ofdImport.FilterIndex = 1;
                    ofdImport.RestoreDirectory = true;

                    if (ofdImport.ShowDialog() != DialogResult.OK)
                        return;

                    string connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Extended Properties=Excel 12.0;", ofdImport.FileName);
                    OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Download factuur in Excel$]", connectionString);

                    DataSet ds = new DataSet();
                    adapter.Fill(ds);

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (dr[18].ToString() == "" || dr[18].ToString().Trim() == "hoeveelheid") // Do not import header or empty rows from Excel
                            continue;

                        Enumeration.Fuel.FuelType fuelType;
                        switch(dr[17].ToString().ToLower())
                        {
                            case "adblue":
                                fuelType = Enumeration.Fuel.FuelType.Unknown ;
                                break;
                            case "diesel 10 ppm":
                                fuelType = Enumeration.Fuel.FuelType.Diesel ;
                                break;
                            case "excellium diesel":
                                fuelType = Enumeration.Fuel.FuelType.Diesel ;
                                break;
                            default:
                                fuelType = Enumeration.Fuel.FuelType.Unknown;
                                break;
                        }

                        string currency = dr[28].ToString().ToLower().Trim();
                        if (currency.ToLower() != "eur" && currency.ToLower() != "pln")
                        {
                            XtraMessageBox.Show("Wisselkoers niet gekend", "De wisselkoers " + currency + "is niet gekend!" , MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            continue;
                        }

                        if (fuelType == Enumeration.Fuel.FuelType.Diesel)
                        {
                            string licenseplate = "";
                            string employeename = "";
                            if (dr[12].ToString() != "")
                            {
                                int space1 = dr[12].ToString().IndexOf(' ');
                                licenseplate = dr[12].ToString().Substring(0, space1);
                                employeename = dr[12].ToString().Substring(space1 + 1);
                            }

                            TIS.DL.Internal.Fuel.FuelObject fuelObj = new FuelObject();
                            fuelObj.Btw = Convert.ToDecimal(dr[21].ToString());
                            fuelObj.CompanyTanking = false;
                            fuelObj.Date = Convert.ToDateTime(dr[15].ToString());
                            fuelObj.Employee = employeename;
                            fuelObj.EmployeeName = employeename;
                            fuelObj.FuelType = fuelType;
                            fuelObj.InvoiceOK = false;
                            fuelObj.InvoiceReceived = false;
                            fuelObj.Location = dr[26].ToString() + " -- " + dr[30].ToString();
                            fuelObj.PrivateTanking = false;
                            fuelObj.Quantity = Convert.ToDecimal(dr[18].ToString());
                            fuelObj.QuantityCorrection = 0;
                            fuelObj.Supplier = "TOTAL";
                            fuelObj.TotalPrice = Convert.ToDecimal(dr[20].ToString());
                            fuelObj.UnityPrice = Convert.ToDecimal(dr[20].ToString()) /  Convert.ToDecimal(dr[18].ToString());
                            fuelObj.VehicleKilometreCounter = Convert.ToInt32(Math.Round(Convert.ToDecimal(dr[31].ToString()),0));
                            fuelObj.VehicleLicensePlate = licenseplate;

                            if (currency == "pln")
                            {
                                decimal pln = Convert.ToDecimal(txtPLNCurrency.Text);
                                fuelObj.Btw = fuelObj.Btw / pln;
                                fuelObj.TotalPrice = fuelObj.TotalPrice / pln;
                                fuelObj.UnityPrice = fuelObj.UnityPrice / pln;
                            }

                            TIS.BL.Internal.Fuel fuelBL = new BL.Internal.Fuel();
                            fuelBL.Save(fuelObj);
                        }
                    }
                    XtraMessageBox.Show("Geïmporteerd", "Bestand is geïmporteerd.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Filter();
                }
                catch (System.Exception excepion1)
                {
                    System.Exception thisException = excepion1;
                    Management.ShowException(thisException);
                }
            }
            catch (System.Exception excepion1)
            {
                System.Exception thisException = excepion1;
                Management.ShowException(thisException);
            }
        }
Ejemplo n.º 4
0
        private void btnImportTotal_Click(object sender, EventArgs e)
        {
            try
            {

                try
                {
                    OpenFileDialog ofdImport = new OpenFileDialog();
                    ofdImport.Title = "Select file";
                    ofdImport.Filter = "Excel Sheet(*.xlsx)|*.xlsx|Excel Sheet 2003(*.xls)|*.xls|All Files(*.*)|*.*";
                    ofdImport.FilterIndex = 1;
                    ofdImport.RestoreDirectory = true;

                    if (ofdImport.ShowDialog() != DialogResult.OK)
                        return;

                    string connectionString = string.Format("Provider=Microsoft.ACE.OLEDB.12.0; data source={0}; Extended Properties=Excel 12.0;", ofdImport.FileName);
                    OleDbDataAdapter adapter = new OleDbDataAdapter("SELECT * FROM [Download factuur in Excel$]", connectionString);

                    DataSet ds = new DataSet();
                    adapter.Fill(ds);

                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        if (dr[18].ToString() == "" || dr[18].ToString().Trim() == "hoeveelheid") // Do not import header or empty rows from Excel
                            continue;

                        Enumeration.Fuel.FuelType fuelType;
                        switch(dr[17].ToString().ToLower())
                        {
                            case "adblue":
                                fuelType = Enumeration.Fuel.FuelType.Unknown ;
                                break;
                            case "diesel 10 ppm":
                                fuelType = Enumeration.Fuel.FuelType.Diesel ;
                                break;
                            case "excellium diesel":
                                fuelType = Enumeration.Fuel.FuelType.Diesel ;
                                break;
                            default:
                                fuelType = Enumeration.Fuel.FuelType.Unknown;
                                break;
                        }

                        string currency = dr[28].ToString().ToLower().Trim();
                        if (currency.ToLower() != "eur" && currency.ToLower() != "pln")
                        {
                            XtraMessageBox.Show("Wisselkoers niet gekend", "De wisselkoers " + currency + "is niet gekend!" , MessageBoxButtons.OK, MessageBoxIcon.Warning);
                            continue;
                        }

                        if (fuelType == Enumeration.Fuel.FuelType.Diesel)
                        {
                            string licenseplate = "";
                            string employeename = "";
                            if (dr[12].ToString() != "")
                            {
                                int space1 = dr[12].ToString().IndexOf(' ');
                                licenseplate = dr[12].ToString().Substring(0, space1);
                                employeename = dr[12].ToString().Substring(space1 + 1);
                            }

                            TIS.DL.Internal.Fuel.FuelObject fuelObj = new FuelObject();
                            fuelObj.Btw = Convert.ToDecimal(dr[21].ToString());
                            fuelObj.CompanyTanking = false;
                            fuelObj.Date = Convert.ToDateTime(dr[15].ToString());
                            fuelObj.Employee = employeename;
                            fuelObj.EmployeeName = employeename;
                            fuelObj.FuelType = fuelType;
                            fuelObj.InvoiceOK = false;
                            fuelObj.InvoiceReceived = false;
                            fuelObj.Location = dr[26].ToString() + " -- " + dr[30].ToString();
                            fuelObj.PrivateTanking = false;
                            fuelObj.Quantity = Convert.ToDecimal(dr[18].ToString());
                            fuelObj.QuantityCorrection = 0;
                            fuelObj.Supplier = "TOTAL";
                            fuelObj.TotalPrice = Convert.ToDecimal(dr[20].ToString());
                            fuelObj.UnityPrice = Convert.ToDecimal(dr[20].ToString()) /  Convert.ToDecimal(dr[18].ToString());
                            fuelObj.VehicleKilometreCounter = Convert.ToInt32(Math.Round(Convert.ToDecimal(dr[31].ToString()),0));
                            fuelObj.VehicleLicensePlate = licenseplate;

                            if (currency == "pln")
                            {
                                decimal pln = Convert.ToDecimal(txtPLNCurrency.Text);
                                fuelObj.Btw = fuelObj.Btw / pln;
                                fuelObj.TotalPrice = fuelObj.TotalPrice / pln;
                                fuelObj.UnityPrice = fuelObj.UnityPrice / pln;
                            }

                            TIS.BL.Internal.Fuel fuelBL = new BL.Internal.Fuel();
                            fuelBL.Save(fuelObj);
                        }
                    }
                    XtraMessageBox.Show("Geïmporteerd", "Bestand is geïmporteerd.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    Filter();
                }
                catch (System.Exception excepion1)
                {
                    System.Exception thisException = excepion1;
                    Management.ShowException(thisException);
                }
            }
            catch (System.Exception excepion1)
            {
                System.Exception thisException = excepion1;
                Management.ShowException(thisException);
            }
        }