Example #1
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            if (!AddContact)
            {
                tblCustomer customer = new tblCustomer()
                {
                    customer_name = txtCustormerName.Text,
                    latitude      = Convert.ToDecimal(txtLatitude.Text),
                    longitude     = Convert.ToDecimal(txtLongitude.Text)
                };

                int customerId = customerRep.AddCustomer(customer);

                tblContact contact = new tblContact()
                {
                    contact_name   = txtContactName.Text,
                    contact_email  = txtContactEmail.Text,
                    contact_number = txtContactNumber.Text,
                    customer_id    = customerId
                };
                contactRep.AddContact(contact);
                ClearTextBoxes();
            }
            else
            {
                tblContact contact = new tblContact()
                {
                    contact_name   = txtContactName.Text,
                    contact_email  = txtContactEmail.Text,
                    contact_number = txtContactNumber.Text,
                    customer_id    = CustomerId
                };
                contactRep.AddContact(contact);
                ClearTextBoxes();
            }

            CustomerListForm listForm = new CustomerListForm();

            listForm.Show();
        }
Example #2
0
        private void CustomerForm_Load(object sender, EventArgs e)
        {
            if (AddContact)
            {
                var Customer = customerRep.GetCustomerById(customerid);

                txtCustormerName.Text = Customer.customer_name;
                txtLatitude.Text      = Customer.latitude.ToString();
                txtLongitude.Text     = Customer.longitude.ToString();

                if (txtContactName.Text != "")
                {
                    tblContact contact = new tblContact()
                    {
                        contact_name   = txtContactName.Text,
                        contact_email  = txtContactEmail.Text,
                        contact_number = txtContactNumber.Text,
                        customer_id    = customerid
                    };
                    contactRep.AddContact(contact);
                }
            }
        }