Example #1
0
        private void button4_Click(object sender, EventArgs e)
        {
            DbTreatments db = new DbTreatments();

            WindowsFormsApplication1.Treatment w = new WindowsFormsApplication1.Treatment();
            try
            {
                w.Id           = int.Parse(textBox1.Text);
                w.CustometId   = int.Parse(comboBox2.Text);
                w.CustomerName = textBox6.Text;
                w.WorkerId     = int.Parse(comboBox3.Text);
                w.WorkerName   = textBox7.Text;
                w.Date         = dateTimePicker2.Text;
                w.Time         = "";
                w.CarId        = int.Parse(comboBox4.Text);
                w.CarKind      = textBox4.Text;
                w.Total        = int.Parse(textBox9.Text);
            }
            catch (Exception exception)
            {
                MessageBox.Show("Invalid parameters", "Error");
                return;
            }

            if (db.TreatmentExist(w.Id))
            {
                MessageBox.Show("Treatment ID already exist , pick other ID", "Error");
                return;
            }


            db.insertTreatment(w);



            WindowsFormsApplication1.InvoiceDetails invoice = new WindowsFormsApplication1.InvoiceDetails();

            invoice.CodeTreatment = w.Id;
            invoice.InvoiceNumber = w.Id;
            invoice.ClientId      = w.CustometId;
            invoice.Kind          = w.CarKind;
            invoice.Price         = w.Total;

            db.insertInvoice(invoice);



            MessageBox.Show("add Treatment Success");
        }
Example #2
0
        public void insertInvoice(WindowsFormsApplication1.InvoiceDetails w)
        {
            string SqlStr = string.Format("insert into InvoiceDetails(CodeTreatment, InvoiceNumber, ClientId, Price, Kind)values({0},{1},{2},{3},'{4}')", w.CodeTreatment, w.InvoiceNumber, w.ClientId, w.Price, w.Kind);

            InsDelUpd(SqlStr);
        }