private void button9_Click(object sender, EventArgs e)
        {
            this.Hide();
            Cus x = new Cus();

            x.Show();
        }
Ejemplo n.º 2
0
        private void deleteButton_Click(object sender, EventArgs e)
        {
            Cus cus = new Cus();


            if (nameTextBox.Text == "")
            {
                MessageBox.Show("Please enter Name.");
                return;
            }

            cus.Code     = codeTextBox.Text;
            cus.Name     = nameTextBox.Text;
            cus.Contact  = contactTextBox.Text;
            cus.Address  = addressTextBox.Text;
            cus.District = districtComboBox.Text;

            try
            {
                if (_customerManager.Delete(cus))
                {
                    MessageBox.Show("Deleted");
                }
                else
                {
                    MessageBox.Show("Not Deleted");
                }

                Clear();
            }



            catch (Exception excp)
            {
                MessageBox.Show(excp.Message);
            }
        }
Ejemplo n.º 3
0
        // public void Display()
        //{
        //    //SqlConnection sqlConnection = new SqlConnection(connectionString);
        //    //string commandString = @"SELECT Name, Contact, Address FROM Customer";
        //    //SqlCommand sqlCommand = new SqlCommand(commandString, sqlConnection);

        //    //SqlDataAdapter sqlDataAdapter = new SqlDataAdapter(sqlCommand);
        //    //DataTable dataTable = new DataTable();
        //    //int isFill = sqlDataAdapter.Fill(dataTable);

        //    //if (isFill > 0)
        //    //{
        //    //    dataGridView.DataSource = dataTable;
        //    //    return 1;
        //    //}
        //    //else
        //    //{
        //    //    dataGridView.DataSource = "";
        //    //    return 0;
        //    //}
        //    dataGridView.DataSource = _customerManager.ShowData();



        // }

        private void addButton_Click(object sender, EventArgs e)
        {
            Cus cus = new Cus();

            if (nameTextBox.Text == "" || contactTextBox.Text == "" || addressTextBox.Text == "")
            {
                MessageBox.Show("Field must not be emptay..");
                Clear();
                return;
            }



            if (Code.Text.Length > 4)
            {
                MessageBox.Show("Can Enter only Four Characters in this Textbox.", "Textbox", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            if (Contact.Text.Length > 11)
            {
                MessageBox.Show("Can Enter only Eleven Characters in this Textbox.", "Textbox", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }


            if (_customerManager.IsNameExist(cus))
            {
                MessageBox.Show(nameTextBox.Text + "Already Exits");
                Clear();
                return;
            }



            if (nameTextBox.Text == "" || contactTextBox.Text == "" || addressTextBox.Text == "")
            {
                MessageBox.Show("Field must not be emptay..");
                Clear();
                return;
            }


            cus.Code     = codeTextBox.Text;
            cus.Name     = nameTextBox.Text;
            cus.Contact  = contactTextBox.Text;
            cus.Address  = addressTextBox.Text;
            cus.District = districtComboBox.Text;


            if (_customerManager.Add(cus))
            {
                MessageBox.Show("Saved");
                dataGridView.DataSource = _customerManager.ShowData();
            }



            else
            {
                MessageBox.Show("Not Saved");
            }

            Clear();
        }