Ejemplo n.º 1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            invoiceModel.hirerName           = txtName.Text;
            invoiceModel.hirerAddress        = txtAddress.Text;
            invoiceModel.hirerTelNo          = txtTelNo.Text;
            invoiceModel.hirerIdentityNo     = txtIdNo.Text;
            invoiceModel.hirerCarRegNo       = txtCarReg.Text;
            invoiceModel.hirerCarMakeModel   = txtMakeModel.Text;
            invoiceModel.addressWhereUsed    = txtAddressWhereUsed.Text;
            invoiceModel.specialInstructions = txtSpecialInstructions.Text ?? "";

            var splitName = txtName.Text.Split(' ');

            TrompsEntities1 context       = new TrompsEntities1();
            var             existsAlready = (from a in context.Customers where a.ID_Number == txtIdNo.Text select a).FirstOrDefault();

            if (existsAlready == null)
            {
                context.Customers.Add(new Customer {
                    First_Name = splitName[0], Last_Name = splitName[1], Address = txtAddress.Text, ID_Number = txtIdNo.Text, Telphone_Number = txtTelNo.Text
                });
            }

            context.SaveChanges();

            Invoice2 invoice2 = new Invoice2();

            this.Close();
            invoice2.Show();
        }
Ejemplo n.º 2
0
        private void Invoice2_Load(object sender, EventArgs e)
        {
            txtInvoiceNo.Text = Invoice1.InvoiceNo.ToString();
            invModel          = Invoice1.invoiceModel;

            using (var context = new TrompsEntities1())
            {
                machines = (from a in context.Machines select a).ToList();
                var equipList = (from a in context.Machines select a.Machine_Name).Distinct().ToArray();

                comboEquip1.Items.AddRange(equipList);
                comboEquip2.Items.AddRange(equipList);
                comboEquip3.Items.AddRange(equipList);
            }

            txtInitialAmount.Focus();
        }