Beispiel #1
0
        void updateBoxes()
        {
            DbClients dbc      = new DbClients();
            int       ClientId = int.Parse(comboBox2.Text);

            textBox6.Text = (string)dbc.GetClientInfo(ClientId).Tables[0].Rows[0]["FirstName"];
            //textBox6.Text = dbc.GetClientInfo(2).Tables[0].Columns[0].Table.ToString();
            //textBox7.Text=dbc.GetClientInfo(2).Tables[0].Columns[0].Table.ToString();

            DbCars dbca = new DbCars();

            if (comboBox4.Text != "")
            {
                int carId = int.Parse(comboBox4.Text);
                textBox4.Text = (string)dbca.getCarInfo(carId).Tables[0].Rows[0]["Kind"];
            }


            DbWorker dbw = new DbWorker();

            if (comboBox3.Text != "")
            {
                int wId = int.Parse(comboBox3.Text);
                textBox7.Text = (string)dbw.getWorkerInfo(wId).Tables[0].Rows[0]["FirstName"];
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            DbCars db = new DbCars();

            WindowsFormsApplication1.Car w = new WindowsFormsApplication1.Car();
            try
            {
                w.Id       = int.Parse(textBox1.Text);
                w.Kind     = textBox3.Text;
                w.Color    = textBox2.Text;
                w.ClientId = int.Parse(textBox4.Text);
                w.History  = int.Parse(textBox5.Text);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Invalid parameters", "Error");
                return;
            }


            DbClients cdb = new DbClients();

            if (!cdb.ClientExist(w.ClientId))
            {
                MessageBox.Show("Invalid Client", "Error");
                return;
            }



            db.insertCar(w);
            MessageBox.Show("add Car Success");
        }
Beispiel #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            DbClients db = new DbClients();

            WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client();
            try
            {
                w.Id = int.Parse(textBox1.Text);
                if (db.ClientExist(w.Id) == true)
                {
                    DialogResult dialogResult = MessageBox.Show("Are You Sure To Delete Client?", "Delete", MessageBoxButtons.YesNoCancel);
                    if (dialogResult == DialogResult.Yes)
                    {
                        db.DeleteClient(w);
                        MessageBox.Show("Delete Client");
                    }
                }
                else
                {
                    MessageBox.Show("Client with similar ID wat not found , try again", "Error");
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Beispiel #4
0
        private void button3_Click(object sender, EventArgs e)
        {
            WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client();
            DbClients db = new DbClients();
            DataSet   ds = new DataSet();

            try
            {
                w.Id = int.Parse(textBox1.Text);
                if (db.ClientExist(w.Id) == true)
                {
                    ds            = db.GetClientInfo(w);
                    textBox1.Text = ds.Tables[0].Rows[0]["ClientId"].ToString();
                    textBox3.Text = ds.Tables[0].Rows[0]["FirstName"].ToString();
                    textBox2.Text = ds.Tables[0].Rows[0]["LastName"].ToString();
                    textBox4.Text = ds.Tables[0].Rows[0]["Address"].ToString();
                    textBox5.Text = ds.Tables[0].Rows[0]["Phone"].ToString();
                }
                else
                {
                    textBox1.Text = "Client not found ";
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #5
0
        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                WindowsFormsApplication1.Car w = new WindowsFormsApplication1.Car();
                DbCars db = new DbCars();
                w.Id       = int.Parse(textBox1.Text);
                w.Kind     = textBox3.Text;
                w.Color    = textBox2.Text;
                w.ClientId = int.Parse(textBox4.Text);
                w.History  = int.Parse(textBox5.Text);

                DbClients cdb = new DbClients();


                if (!cdb.ClientExist(w.ClientId))
                {
                    MessageBox.Show("Client Does not exist");
                    return;
                }

                db.UpdateCar(w);
                MessageBox.Show("Successfully updated Car");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #6
0
        private void button1_Click(object sender, EventArgs e)
        {
            DbClients db = new DbClients();

            try
            {
                if (comboBox1.SelectedIndex == 0)
                {
                    WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client();
                    w.Id = int.Parse(textBox1.Text);
                    if (db.ClientExist(w.Id) == true)
                    {
                        dataGridView1.DataSource = db.SearchClientbyId(w.Id).Tables[0];
                    }
                }
                else
                {
                    dataGridView1.DataSource = db.SearchClientbyName(textBox3.Text).Tables[0];
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }
Beispiel #7
0
        private void button1_Click(object sender, EventArgs e)
        {
            WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client();
            DbClients db = new DbClients();

            w.Id        = int.Parse(textBox1.Text);
            w.FirstName = textBox3.Text;
            w.LastName  = textBox2.Text;
            w.Address   = textBox4.Text;
            w.Phone     = textBox5.Text;
            db.UpdateClient(w);
            MessageBox.Show("Successfully updated client");
        }
Beispiel #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            DbClients db = new DbClients();

            WindowsFormsApplication1.Client w = new WindowsFormsApplication1.Client();
            try
            {
                w.Id        = int.Parse(textBox1.Text);
                w.FirstName = textBox3.Text;
                w.LastName  = textBox2.Text;
                w.Address   = textBox4.Text;
                w.Phone     = textBox5.Text;
            }
            catch (Exception exception)
            {
                MessageBox.Show("Invalid parameters", "Error");
                return;
            }
            db.InsertClient(w);
            MessageBox.Show("add workstation Success");
        }
Beispiel #9
0
        private void AddTreatment_Load(object sender, EventArgs e)
        {
            DbKindTreatments db  = new DbKindTreatments();
            DataSet          ds  = db.GetAllKindTreatments();
            DataSet          ds2 = ds.Clone();

            dataGridView1.DataSource = ds.Tables[0];

            dataGridView1.AllowUserToAddRows = false;
            dataGridView2.AllowUserToAddRows = false;

            foreach (DataGridViewColumn col in dataGridView1.Columns)
            {
                dataGridView2.Columns.Add((DataGridViewColumn)col.Clone());
            }


            DbClients dbc = new DbClients();

            comboBox2.DisplayMember = "ClientId";
            comboBox2.ValueMember   = "ClientId";
            comboBox2.DataSource    = dbc.GetAllClients().Tables[0].Columns[0].Table;


            comboBox3.DisplayMember = "WorkerId";
            comboBox3.ValueMember   = "WorkerId";
            DbWorker dbw = new DbWorker();

            comboBox3.DataSource = dbw.GetAllWorkers().Tables[0].Columns[0].Table;


            comboBox4.DisplayMember = "ProductCode";
            comboBox4.ValueMember   = "ProductCode";
            DbCars dbca = new DbCars();

            comboBox4.DataSource = dbca.GetAllCars().Tables[0].Columns[0].Table;


            textBox9.Text = "0";
        }
Beispiel #10
0
        private void button1_Click(object sender, EventArgs e)
        {
            DbCalls db = new DbCalls();

            WindowsFormsApplication1.Call w = new WindowsFormsApplication1.Call();
            try
            {
                w.Id          = int.Parse(textBox1.Text);
                w.CallDate    = textBox3.Text;
                w.CallTime    = textBox2.Text;
                w.WorkerId    = int.Parse(textBox4.Text);
                w.ClientId    = int.Parse(textBox5.Text);
                w.Description = textBox6.Text;


                DbWorker  wdb = new DbWorker();
                DbClients cdb = new DbClients();

                if (!wdb.WorkerExist(w.WorkerId))
                {
                    MessageBox.Show("Invalid Worker", "Error");
                    return;
                }

                if (!cdb.ClientExist(w.ClientId))
                {
                    MessageBox.Show("Invalid Client", "Error");
                    return;
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show("Invalid parameters", "Error");
                return;
            }
            db.insertCall(w);
            MessageBox.Show("add workstation Success");
        }
Beispiel #11
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            DbClients db = new DbClients();

            dataGridView1.DataSource = db.GetAllClients().Tables[0];
        }