Пример #1
0
        private void viewUser_Load(object sender, EventArgs e)
        {
            string query = "select * from tblvehicle where tblvehicle.vehicleID = '" + GlobalLoginData.vehicleId + "'";
            int    rows  = DatabaseHandler.returnRowCountWithoutParams(query);

            if (rows == 1)
            {
                btnEdit.Show();

                txtVehicleRegNo.Text             = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleRegNo");
                txtMake.Text                     = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleMake");
                cmbModel.SelectedText            = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleModel");
                cmbVehicleStatus.SelectedText    = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleStatus");
                cmbFuelType.SelectedText         = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleFuelType");
                cmbTransmissionGear.SelectedText = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleTransmissionGear");
                txtChassisNo.Text                = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleChasisNo");
                txtEngineNo.Text                 = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleEngineNo");
                txtCylinderCapacity.Text         = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleCylinderCapacity");
                txtColor.Text                    = DatabaseHandler.returnOneValueWithoutParams(query, "vehicleColor");
                cmbOriginCountry.SelectedText    = DatabaseHandler.returnOneValueWithoutParams(query, "countryOfOrigin");
                countPreviousOwner.Value         = Convert.ToInt16(DatabaseHandler.returnOneValueWithoutParams(query, "previousOwnerCount"));
                countSeatingCapacity.Value       = Convert.ToInt16(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleSeatingCapacity"));
                countServicesDone.Value          = Convert.ToInt16(DatabaseHandler.returnOneValueWithoutParams(query, "noOfServicesDone"));
                dateFirstRegDate.Value           = Convert.ToDateTime(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleRegDate"));
                dateInsurance.Value              = Convert.ToDateTime(DatabaseHandler.returnOneValueWithoutParams(query, "insuranceDate"));
                yearManufacture.Value            = Convert.ToDateTime(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleManufacturedDate"));
                dateLastService.Value            = Convert.ToDateTime(DatabaseHandler.returnOneValueWithoutParams(query, "lastServiceDate"));
                txtInsuranceType.Text            = DatabaseHandler.returnOneValueWithoutParams(query, "insuranceType");
                txtInsuranceCompany.Text         = DatabaseHandler.returnOneValueWithoutParams(query, "insuranceCompany");
                txtSpecialNotes.Text             = DatabaseHandler.returnOneValueWithoutParams(query, "specialNotes");
                txtVehiclePrice.Text             = DatabaseHandler.returnOneValueWithoutParams(query, "price");

                //byte[] img = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageOne"));
                //byte[] img2 = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageTwo"));
                //byte[] img3 = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageThree"));
                //byte[] img4 = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageFour"));
                //byte[] img5 = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageFive"));
                //byte[] img6 = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageSix"));
                //byte[] img7 = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageSeven"));
                //byte[] img8 = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageEight"));
                //byte[] img9 = Encoding.ASCII.GetBytes(DatabaseHandler.returnOneValueWithoutParams(query, "vehicleImageNine"));

                //picBoxOne.Image = Image.FromStream(new MemoryStream(img));
                //picBoxTwo.Image = Image.FromStream(new MemoryStream(img2));
                //picBoxThree.Image = Image.FromStream(new MemoryStream(img3));
                //picBoxFour.Image = Image.FromStream(new MemoryStream(img4));
                //picBoxFive.Image = Image.FromStream(new MemoryStream(img5));
                //picBoxSix.Image = Image.FromStream(new MemoryStream(img6));
                //picBoxSeven.Image = Image.FromStream(new MemoryStream(img7));
                //picBoxEight.Image = Image.FromStream(new MemoryStream(img8));
                //picBoxNine.Image = Image.FromStream(new MemoryStream(img9));

                txtVehicleRegNo.ReadOnly      = true;
                txtMake.ReadOnly              = true;
                cmbModel.Enabled              = false;
                cmbVehicleStatus.Enabled      = false;
                cmbFuelType.Enabled           = false;
                cmbTransmissionGear.Enabled   = false;
                txtChassisNo.ReadOnly         = true;
                txtCylinderCapacity.ReadOnly  = true;
                txtColor.ReadOnly             = true;
                cmbOriginCountry.Enabled      = false;
                countPreviousOwner.ReadOnly   = true;
                countSeatingCapacity.ReadOnly = true;
                countServicesDone.ReadOnly    = true;
                dateFirstRegDate.Enabled      = false;
                dateInsurance.Enabled         = false;
                yearManufacture.Enabled       = false;
                dateLastService.Enabled       = false;
                txtInsuranceType.ReadOnly     = true;
                txtInsuranceCompany.ReadOnly  = true;
                txtSpecialNotes.ReadOnly      = true;
                picBoxOne.Enabled             = false;
                picBoxTwo.Enabled             = false;
                picBoxThree.Enabled           = false;
                picBoxFour.Enabled            = false;
                picBoxFive.Enabled            = false;
                picBoxSix.Enabled             = false;
                picBoxSeven.Enabled           = false;
                picBoxEight.Enabled           = false;
                picBoxNine.Enabled            = false;
                txtVehiclePrice.ReadOnly      = true;
            }
        }
        private void btnViewMore_Click(object sender, EventArgs e)
        {
            MemoryStream ms1 = new MemoryStream();
            MemoryStream ms2 = new MemoryStream();
            MemoryStream ms3 = new MemoryStream();
            MemoryStream ms4 = new MemoryStream();
            MemoryStream ms5 = new MemoryStream();
            MemoryStream ms6 = new MemoryStream();
            MemoryStream ms7 = new MemoryStream();
            MemoryStream ms8 = new MemoryStream();
            MemoryStream ms9 = new MemoryStream();

            //picBoxOne.Image.Save(ms1, picBoxOne.Image.RawFormat);
            //picBoxTwo.Image.Save(ms2, picBoxTwo.Image.RawFormat);
            //picBoxThree.Image.Save(ms3, picBoxThree.Image.RawFormat);
            //picBoxFour.Image.Save(ms4, picBoxFour.Image.RawFormat);
            //picBoxFive.Image.Save(ms5, picBoxFive.Image.RawFormat);
            //picBoxSix.Image.Save(ms6, picBoxSix.Image.RawFormat);
            //picBoxSeven.Image.Save(ms7, picBoxSeven.Image.RawFormat);
            //picBoxEight.Image.Save(ms8, picBoxEight.Image.RawFormat);
            //picBoxNine.Image.Save(ms9, picBoxNine.Image.RawFormat);

            byte[] img1 = ms1.ToArray();
            byte[] img2 = ms2.ToArray();
            byte[] img3 = ms3.ToArray();
            byte[] img4 = ms4.ToArray();
            byte[] img5 = ms5.ToArray();
            byte[] img6 = ms6.ToArray();
            byte[] img7 = ms7.ToArray();
            byte[] img8 = ms8.ToArray();
            byte[] img9 = ms9.ToArray();

            List <MySqlParameter> paramlist = new List <MySqlParameter>();

            string query = "INSERT INTO tblvehicle VALUES " +
                           "(@RegNo, @customerNIC, @firstRegDate, @status, @chassisNo, @engineNo, @manufactureYear, @cc, @color, @mileage, @fuelType, @Make, @Model, @origin,@TransmissionGear, " +
                           "@seatingCapacity, @ownerCount, @insuType, @insuCompanny, @insuDate, @lastservice, @serviceCount, @img1, @img2, @img3, @img4, @img5, @img6, @img7, @img8, @img9, @notes, @price)";

            paramlist.Clear();
            paramlist.Add(new MySqlParameter("@RegNo", txtVehicleRegNo.Text));
            paramlist.Add(new MySqlParameter("@customerNIC", GlobalLoginData.customerId));
            paramlist.Add(new MySqlParameter("@Make", txtMake.Text));
            paramlist.Add(new MySqlParameter("@Model", cmbModel.SelectedText));
            paramlist.Add(new MySqlParameter("@status", cmbVehicleStatus.SelectedText));
            paramlist.Add(new MySqlParameter("@fuelType", cmbFuelType.SelectedText));
            paramlist.Add(new MySqlParameter("@TransmissionGear", cmbTransmissionGear.SelectedText));
            paramlist.Add(new MySqlParameter("@mileage", txtVehicleMileage.Text));
            paramlist.Add(new MySqlParameter("@chassisNo", txtChassisNo.Text));
            paramlist.Add(new MySqlParameter("@engineNo", txtEngineNo.Text));
            paramlist.Add(new MySqlParameter("@cc", txtCylinderCapacity.Text));
            paramlist.Add(new MySqlParameter("@color", txtColor.Text));
            paramlist.Add(new MySqlParameter("@origin", cmbOriginCountry.SelectedText));
            paramlist.Add(new MySqlParameter("@ownerCount", countPreviousOwner.Value));
            paramlist.Add(new MySqlParameter("@seatingCapacity", countSeatingCapacity.Value));
            paramlist.Add(new MySqlParameter("@serviceCount", countServicesDone.Value));
            paramlist.Add(new MySqlParameter("@firstRegDate", dateFirstRegDate.Value));
            paramlist.Add(new MySqlParameter("@insuType", txtInsuranceType.Text));
            paramlist.Add(new MySqlParameter("@insuCompanny", txtInsuranceCompany.Text));
            paramlist.Add(new MySqlParameter("@insuDate", dateInsurance.Value));
            paramlist.Add(new MySqlParameter("@manufactureYear", yearManufacture.Value));
            paramlist.Add(new MySqlParameter("@lastservice", dateLastService.Value));
            paramlist.Add(new MySqlParameter("@notes", txtSpecialNotes.Text));
            paramlist.Add(new MySqlParameter("@img1", null));
            paramlist.Add(new MySqlParameter("@img2", null));
            paramlist.Add(new MySqlParameter("@img3", null));
            paramlist.Add(new MySqlParameter("@img4", null));
            paramlist.Add(new MySqlParameter("@img5", null));
            paramlist.Add(new MySqlParameter("@img6", null));
            paramlist.Add(new MySqlParameter("@img7", null));
            paramlist.Add(new MySqlParameter("@img8", null));
            paramlist.Add(new MySqlParameter("@img9", null));
            paramlist.Add(new MySqlParameter("@price", txtVehiclePrice.Text));

            int rowsAffedted = DatabaseHandler.insertOrDeleteRow(query, paramlist);


            if (rowsAffedted >= 0)
            {
                try
                {
                    if (!frmHomepage.Instance.pnlcontainer.Controls.Contains(ucSearchCars.Instance))
                    {
                        frmHomepage.Instance.pnlcontainer.Controls.Add(ucSearchCars.Instance);
                        ucSearchCars.Instance.Dock = DockStyle.Fill;
                        ucSearchCars.Instance.BringToFront();
                    }
                    else
                    {
                        ucSearchCars.Instance.BringToFront();
                    }
                }
                catch (Exception)
                {
                    MessageBox.Show("Operation Unsuccessful!");
                }
            }
            else
            {
                MessageBox.Show("Error Occured!");
            }
        }
Пример #3
0
        private void ucInsuranceLuxary_Load(object sender, EventArgs e)
        {
            string query = "SELECT customerName as 'Customer Name', vehicleModel as 'Model', vehicleMake as 'Make' from tblinquiries";

            DatabaseHandler.populateGridViewWithBinding(query, dgridNotifications);
        }
Пример #4
0
        private void cmbMakeAllCarDetails_SelectedIndexChanged(object sender, EventArgs e)
        {
            string query = "SELECT vehicleStatus as 'Status', vehicleRegNo as 'Registartion No', vehicleModel as 'Model', vehicleMake as 'Make', vehicleMileage as 'Mileage', vehicleManufacturedDate as 'Maufactured Year' from tblvehicle WHERE tblvehicle.vehicleModel like '%" + cmbModel.SelectedText + "%'";

            DatabaseHandler.populateGridViewWithBinding(query, dgridCarsAllCarDetails);
        }
Пример #5
0
        private void dateTimePickerYearofManufactureAllCarDetails_ValueChanged(object sender, EventArgs e)
        {
            string query = "SELECT vehicleStatus as 'Status', vehicleRegNo as 'Registartion No', vehicleModel as 'Model', vehicleMake as 'Make', vehicleMileage as 'Mileage', vehicleManufacturedDate as 'Maufactured Year' from tblvehicle WHERE tblvehicle.vehicleManufacturedDate like '%" + dateManufactured.Value + "%'";

            DatabaseHandler.populateGridViewWithBinding(query, dgridCarsAllCarDetails);
        }
Пример #6
0
        private void ucSearchCars_Load(object sender, EventArgs e)
        {
            string query = "SELECT vehicleID as 'ID', vehicleStatus as 'Status', vehicleRegNo as 'Registartion No', vehicleModel as 'Model', vehicleMake as 'Make', vehicleMileage as 'Mileage', vehicleManufacturedDate as 'Maufactured Year' from tblvehicle";

            DatabaseHandler.populateGridViewWithBinding(query, dgridCarsAllCarDetails);
        }