public FormMasterVehicle()
        {
            InitializeComponent();
            FormClosing += (o, e) => Program.GetInstanceOf(typeof(MainForm)).Show();
            member_id    = new TextBox();

            txtFilter.TextChanged += (o, e) =>
            {
                PopulateDate(txtFilter.Text);
            };

            this.context = new MandhegParkingSystemDataContext();

            cbxFilterby.Items.Add("Owner Name");
            cbxFilterby.Items.Add("License Plate");
            cbxFilterby.SelectedIndex = 0;

            cbxVehicleType.DataSource    = context.VehicleTypes.ToList();
            cbxVehicleType.DisplayMember = "name";
            cbxVehicleType.ValueMember   = "id";


            FormState             = FormState.Default;
            txtOwner.TextChanged += (o, e) => member_id.Text = txtOwner.Text;


            dataGridView1.CellClick += (o, e) =>
            {
                member_id.DataBindings.Clear();
                foreach (Control item in Controls)
                {
                    if (item != dataGridView1)
                    {
                        item.DataBindings.Clear();
                    }
                }
                if (e.RowIndex > 0)
                {
                    current_id = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                }

                FormState = FormState.Select;
                member_id.DataBindings.Add("Text", dataGridView1.DataSource, "member_id");
                txtPlate.DataBindings.Add("Text", dataGridView1.DataSource, "license_plate");
                cbxVehicleType.DataBindings.Add("SelectedValue", dataGridView1.DataSource, "type_id");
                txtOwner.DataBindings.Add("Text", dataGridView1.DataSource, "member_id");
                txtNotes.DataBindings.Add("Text", dataGridView1.DataSource, "notes");

                FormState = FormState.Select;
            };
        }
        public FormMasterMember()
        {
            InitializeComponent();
            //MessageBox.Show(DateTime.Now.ToString("yyyy/MM/dd"));

            FormClosing += (o, e) => Program.GetInstanceOf(typeof(MainForm)).Show();
            //current_id = new TextBox();

            this.context = new MandhegParkingSystemDataContext();

            cbxGender.Items.Add("Male");
            cbxGender.Items.Add("Female");
            cbxGender.SelectedIndex = 0;

            cbxMemberType.DataSource = context.Memberships.Where(x => x.name != "Non Member").Select(x => x.name).ToList();


            FormState = FormState.Default;


            dataGridView1.CellClick += (o, e) =>
            {
                foreach (Control item in Controls)
                {
                    if (item != dataGridView1)
                    {
                        item.DataBindings.Clear();
                    }
                }

                if (e.RowIndex > 0)
                {
                    current_id = int.Parse(dataGridView1.Rows[e.RowIndex].Cells[0].Value.ToString());
                }

                FormState = FormState.Select;
                txtName.DataBindings.Add("Text", dataGridView1.DataSource, "name");
                cbxMemberType.DataBindings.Add("Text", dataGridView1.DataSource, "Membership_Name");
                txtEmail.DataBindings.Add("Text", dataGridView1.DataSource, "email");
                txtPhone.DataBindings.Add("Text", dataGridView1.DataSource, "phone_number");
                txtAddresss.DataBindings.Add("Text", dataGridView1.DataSource, "address");
                dtpDateOfBirth.DataBindings.Add("Text", dataGridView1.DataSource, "date_of_birth");
                cbxGender.DataBindings.Add("Text", dataGridView1.DataSource, "gender");
            };
        }
예제 #3
0
        public FormPayment()
        {
            context = Program.GetContext();

            InitializeComponent();

            FormClosing                += (o, e) => Program.GetInstanceOf(typeof(MainForm)).Show();
            dtpInTime.Format            = DateTimePickerFormat.Time;
            dtpOutTime.Format           = DateTimePickerFormat.Time;
            cbxMemberType.DataSource    = context.Memberships.ToList();
            cbxMemberType.DisplayMember = "name";
            cbxMemberType.ValueMember   = "id";
            cbxMemberType.SelectedIndex = 0;

            cbxVehicleType.DataSource    = context.VehicleTypes.ToList();
            cbxVehicleType.DisplayMember = "name";
            cbxVehicleType.ValueMember   = "id";
            cbxVehicleType.SelectedIndex = 0;


            var P = context.Vehicles.Where(x => x.license_plate == txtPlate.Text).FirstOrDefault();

            if (P is null)
            {
                tbxOwner.Text                = "";
                tbxOwner.Enabled             = true;
                cbxMemberType.Enabled        = true;
                cbxMemberType.SelectedItem   = "No Member";
                cbxVehicleType.Enabled       = true;
                cbxVehicleType.SelectedIndex = 0;
            }
            else
            {
                var owner = context.Members.Where(x => x.id == context.Vehicles.Where(y => y.license_plate == P.license_plate).FirstOrDefault().id).FirstOrDefault();
                tbxOwner.Text                = owner.name;
                tbxOwner.Enabled             = false;
                cbxMemberType.Enabled        = false;
                cbxMemberType.SelectedValue  = owner.membership_id;
                cbxVehicleType.Enabled       = false;
                cbxVehicleType.SelectedValue = P.vehicle_type_id;
            }



            txtPlate.TextChanged += (o, e) =>
            {
                var plate = context.Vehicles.Where(x => x.license_plate == txtPlate.Text).FirstOrDefault();
                if (plate is null)
                {
                    tbxOwner.Text                = "";
                    tbxOwner.Enabled             = true;
                    cbxMemberType.Enabled        = true;
                    cbxMemberType.SelectedItem   = "No Member";
                    cbxVehicleType.Enabled       = true;
                    cbxVehicleType.SelectedIndex = 0;
                }
                else
                {
                    var owner = context.Members.Where(x => x.id == context.Vehicles.Where(y => y.license_plate == plate.license_plate).FirstOrDefault().id).FirstOrDefault();
                    tbxOwner.Text                = owner.name;
                    tbxOwner.Enabled             = false;
                    cbxMemberType.Enabled        = false;
                    cbxMemberType.SelectedValue  = owner.membership_id;
                    cbxVehicleType.Enabled       = false;
                    cbxVehicleType.SelectedValue = plate.vehicle_type_id;
                }
            };

            txtPlate.Text = "";
        }