Exemplo n.º 1
0
        private void custCreateOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;

            // Form input checks:
            if (!String.IsNullOrWhiteSpace(newCustIdText.Text)
                && !string.IsNullOrWhiteSpace(newCustNameText.Text)
                && !string.IsNullOrWhiteSpace(newCustPhoneText.Text)
                && !string.IsNullOrWhiteSpace(newCustAddressText.Text))
            {
                // ??? ===
                DataManipulation dm = new DataManipulation("customers.txt");

                if (dm.CustomerFind(int.Parse(newCustIdText.Text)) == null)
                {
                    // Customer DOES NOT exist, so Create new:
                    createCustomer(int.Parse(newCustIdText.Text),
                                    newCustNameText.Text,
                                    int.Parse(newCustPhoneText.Text),
                                    newCustAddressText.Text);

                    MessageBox.Show("New customer created: \n\r    - ID: " + newCustIdText.Text
                     + "\n\r    - Name: " + newCustNameText.Text
                     + "\n\r    - Phone: " + newCustPhoneText.Text
                     + "\n\r    - Address: " + newCustAddressText.Text
                     + "\n\r", "Success!");

                    this.Close();
                }
                else
                    this.custCreateResultLbl.Text = "Customer with ID: " + newCustIdText.Text + " already exists!";
            }
            else
                this.custCreateResultLbl.Text = "No fields should be blank!";
        }
Exemplo n.º 2
0
        private void custSearchBtn_Click(object sender, EventArgs e)
        {
            int n;

            if (!string.IsNullOrWhiteSpace(this.wantedCustomerTXT.Text) && (int.TryParse(this.wantedCustomerTXT.Text, out n)))
            {
                // call func to return wanted customersobj
                DataManipulation dm = new DataManipulation("customers.txt");
                Customer cust = dm.CustomerFind(int.Parse(this.wantedCustomerTXT.Text));

                if (cust != null)
                {
                    this.custSearchResultLBL.Text = "Customer found!";
                    this.customerSearchResult.Enabled = true;
                    this.custSearchIDresult.Text = cust.ID.ToString();
                    this.custSearchNameResult.Text = cust.Name;
                    this.custSearchPhoneResult.Text = cust.Phone.ToString();
                    this.custSearchAddressResult.Text = cust.Address;
                }
                else
                {
                    this.customerSearchResult.Enabled = false;
                    this.custSearchResultLBL.Text = "There is no customer with ID: " + this.wantedCustomerTXT.Text + ".";
                }

            }

            else
            {
                this.custSearchResultLBL.ForeColor = System.Drawing.Color.Red;
                this.custSearchResultLBL.Text = "Enter a valid ID!";
            }
        }
Exemplo n.º 3
0
        private void EntryForm_Load(object sender, EventArgs e)
        {
            DataManipulation CustomerFileConnection = new DataManipulation("customers.txt");
            //DataManipulation OrdersFileConnection = new DataManipulation("orders.txt");

            customersGrid.DataSource = CustomerFileConnection.CustomersFetch();
        }
Exemplo n.º 4
0
        private void createCustomer(int id, string name, long phone, string address)
        {
            Customer c = new Customer(id, name, phone, address);

            // NEEDS ERROR CHECKS ???

            //
            DataManipulation dm = new DataManipulation("customers.txt");
            dm.CustomerCreate(c);
        }
Exemplo n.º 5
0
        private void custFoundDelBtn_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure you want to delete this customer?",
                            "Attention!",
                            MessageBoxButtons.YesNo,
                            MessageBoxIcon.Question) == DialogResult.Yes )
            {
                // CDeletion Confirmed. Call Delete func here!!!!! ====================
                DataManipulation dm = new DataManipulation("customers.txt");

                if (dm.CustomerDelete(int.Parse(this.custSearchIDresult.Text)))
                    MessageBox.Show("Deletion OK!");
                else
                    MessageBox.Show("No deletion!");
            }
            else
                this.Close();
        }
Exemplo n.º 6
0
 public DataConnect()
 {
     DataManipulation CustomerDataConnection = new DataManipulation("customers.txt");
     DataManipulation OrdersDataConnection = new DataManipulation("orders.txt");
 }
Exemplo n.º 7
0
        private void OrdersForm_Load(object sender, EventArgs e)
        {
            DataManipulation DataBase = new DataManipulation("orders.txt");

            ordersGrid.DataSource = DataBase.OrdersFetch();
        }