コード例 #1
0
        private void btn_DeleteClient_Click(object sender, EventArgs e)
        {
            clsGLobalVariables.Id = dataResultClient.SelectedRows[0].Cells[0].Value.ToString();

            mycon.Open();
            SqlCommand     mycmddeleteClients = new SqlCommand("DELETE FROM Clients WHERE Name ='" + clsGLobalVariables.Id.ToString() + "'", mycon);
            SqlDataAdapter daClientsdelete    = new SqlDataAdapter(mycmddeleteClients);
            var            dsClientsdelete    = new DataSet();

            daClientsdelete.Fill(dsClientsdelete);
            mycon.Close();
            this.Close();
            MessageBox.Show("The Client has been deleted!", "Delete", MessageBoxButtons.OK, MessageBoxIcon.Information);
            frmClientsView client = new frmClientsView();

            client.Show();
        }
コード例 #2
0
        private void btn_AddClient_Click(object sender, EventArgs e)
        {
            mycon.Open();
            string gender = "";

            if (radioButtonMale.Checked == true)
            {
                gender = radioButtonMale.Text;
            }
            else
            {
                gender = radioButtonFemale.Text;
            }
            //Inserting data in to table
            if (clsGLobalVariables.method == "add")
            {
                SqlCommand mycmdClients = new SqlCommand("INSERT INTO Clients (Name, Email, Phone, Address, Password, Gender, Notes, refEmployee) " +
                                                         " VALUES('" + txt_name.Text + "','" + txt_mail.Text + "','" + txt_phone.Text + "','" + txt_Addr.Text + "','" + txt_pwd.Text + "','" + gender +
                                                         "','" + txt_notes.Text + "','" + cbAgentName.SelectedItem.ToString() + "')", mycon);
                SqlDataAdapter da           = new SqlDataAdapter(mycmdClients);
                var            dsClientsAdd = new DataSet();
                da.Fill(dsClientsAdd);

                MessageBox.Show("Clients is Added Successfully!", "Data Added", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            if (clsGLobalVariables.method == "edit")
            {
                SqlCommand mycmdeditClients = new SqlCommand("UPDATE Clients " +
                                                             "SET Name ='" + txt_name.Text + "', Email ='" + txt_mail.Text +
                                                             "', Phone =" + txt_phone.Text + ", Password ='******', Address ='" + txt_Addr.Text + "', Notes = '" + txt_notes.Text +
                                                             "', Gender ='" + gender + "', refEmployee ='" + cbAgentName.SelectedItem.ToString() + "' WHERE Name = '" + clsGLobalVariables.Id + "'"
                                                             , mycon);
                SqlDataAdapter daeditClients = new SqlDataAdapter(mycmdeditClients);
                var            dsClientsEdit = new DataSet();
                daeditClients.Fill(dsClientsEdit);

                MessageBox.Show("Clients Detail has been Updated!", "Updated", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            mycon.Close();
            this.Close();
            frmClientsView clientsView = new frmClientsView();

            clientsView.Show();
        }
コード例 #3
0
        private void viewClients_Click(object sender, EventArgs e)
        {
            frmClientsView frmClientsView = new frmClientsView();

            frmClientsView.Show();
        }