コード例 #1
0
        public void invoiceUpdate()
        {
            connection.Open();
            MySqlCommand command = new MySqlCommand();

            command.Connection  = connection;
            command.CommandText = "Select Max(CustomerID) From tblHistory";//used the select max we can get the highest incoce num and add one as this info will e saves in the next invoice numbert
            int invoice = 0;

            if (command.Equals(DBNull.Value))//this check if the customer id is null then make inthe invoice equal to 1
            {
                invoice = 1;
            }
            else
            {
                invoice = (int)command.ExecuteScalar() + 1;//if not add one to the last invocie number as it is a new invoice
            }
            txtinvoice.Text = Convert.ToString(invoice);
            connection.Close();
        }
コード例 #2
0
ファイル: dProduits.cs プロジェクト: chance20/test
        public string PublierProduit(publierProduit publierProduit)
        {
            string msg = "";
            string result = ""; string result1 = ""; string result2 = "";

            string query = $@"INSERT INTO [test].[dbo].[Produits]
                           (
                             [CodeProduit]
                              ,[description]
                              ,[photo]
                              ,[designation]
                              ,[prixUnitaire]
                              ,[Monnaie])
                     VALUES
                           (
                           '{publierProduit.CodeProduit}'
                           ,'{publierProduit.description}'
                           ,'{publierProduit.Photo}'
                           ,'{publierProduit.designation}'
                           ,Convert(money,'{publierProduit.prixUnitaire.ToString()}'),'{publierProduit.Monnaie}')
                           ";

            string query1 = $@"INSERT INTO [test].[dbo].[Commande]
                           (
                              [CodeCommande]
                              ,[CodeUtilisateur]
                              ,[Sens]
                              ,[DateCommande])
                              VALUES
                           (
                           '{publierProduit.CodeCommande}'
                           ,'{publierProduit.CodeUtilisateur}'
                           ,'{publierProduit.sens}'
                           ,'{publierProduit.DateCommande}'
                          )
                           ";

            string query2 = $@"INSERT INTO [test].[dbo].[DetailCommande]
                           (
                              [CodeProduit]
                              ,[CodeCommande]
                              ,[QteCommandee]
                              ,[MontantUnitaire]
                              ,[Sens]
                              ,[Monnaie])

                              VALUES
                           (
                           '{publierProduit.CodeProduit}'
                           ,'{publierProduit.CodeCommande}'
                           ,'{publierProduit.QteCommandee}'
                           ,Convert(money,'{publierProduit.MontantUnitaire.ToString()}')
                           ,'{publierProduit.sens}','{publierProduit.Monnaie}')
                           ";



            MySqlConnection sqlConnection = DbConnection.Access.getConnexion();

            using (MySqlTransaction sqlTransaction = sqlConnection.BeginTransaction())
            {
                try
                {
                    result = new MySqlCommand(query, sqlConnection, sqlTransaction)
                             .ExecuteNonQuery() > 0 ? "1" : "0";

                    result1 = new MySqlCommand(query1, sqlConnection, sqlTransaction)
                              .ExecuteNonQuery() > 0 ? "1" : "0";

                    result2 = new MySqlCommand(query2, sqlConnection, sqlTransaction)
                              .ExecuteNonQuery() > 0 ? "1" : "0";

                    if (result.Equals("1") && result1.Equals("1") && result2.Equals("1"))
                    {
                        sqlTransaction.Commit();
                        msg = "1";
                    }

                    else
                    {
                        sqlTransaction.Rollback();
                        msg = "0";
                    }
                }
                catch (Exception ex)
                {
                    DbConnection.Access.sqlTransaction.Rollback();
                    msg = ex.Message;
                }
                finally
                {
                    DbConnection.Access.setCloseConnexion();
                }
            }
            return(msg);
        }
コード例 #3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            connection.ConnectionString = "datasource=192.168.125.30;port=3306;Database=catalogue;Uid=rootX;Pwd=";
            // Everything must be below SetContentView
            SetContentView(Resource.Layout.InvoiceDisplay);
            // Intent that passes all the variables from the previous Activity on to this activity and displaying them
            Intent intent        = Intent;
            string CustomerInput = Intent.GetStringExtra("CustomerInput");

            FindViewById <TextView>(Resource.Id.txtNameResult).Text = CustomerInput;

            string PhoneNumber = intent.GetStringExtra("PhoneNumber");

            FindViewById <TextView>(Resource.Id.txtPhoneResult).Text = PhoneNumber;

            string VehicleNumber = intent.GetStringExtra("VehicleNum");

            FindViewById <TextView>(Resource.Id.txtVehicleYearResult).Text = VehicleNumber;

            string VehicleMake = intent.GetStringExtra("VehicleMake");

            FindViewById <TextView>(Resource.Id.txtVehicleMakeResult).Text = VehicleMake;

            string VehicleModel = intent.GetStringExtra("VehicleModel");

            FindViewById <TextView>(Resource.Id.txtVehicleModelResult).Text = VehicleModel;

            string VinNum = intent.GetStringExtra("VinNum");

            FindViewById <TextView>(Resource.Id.txtVINResult).Text = VinNum;

            string LicensePlate = intent.GetStringExtra("LicensePlate");

            FindViewById <TextView>(Resource.Id.txtLicensePlateResult).Text = LicensePlate;

            string Date = intent.GetStringExtra("Date");

            FindViewById <TextView>(Resource.Id.txtDateofCompletionResult).Text = Date;

            string Km = intent.GetStringExtra("KM");

            FindViewById <TextView>(Resource.Id.txtKMResult).Text = Km;

            // Spinner initialization and calling for the serviceslist method that adds each element into the spinner and the submit button being initialized
            Spinner spinner = FindViewById <Spinner>(Resource.Id.Services);

            connection.Open();
            MySqlCommand command = new MySqlCommand();

            command.Connection  = connection;
            command.CommandText = "Select Max(CustomerID) From tblHistory";//used the select max we can get the highest incoce num and add one as this info will e saves in the next invoice numbert
            int invoice = 0;

            if (command.Equals(DBNull.Value))//this check if the customer id is null then make inthe invoice equal to 1
            {
                invoice = 1;
            }
            else
            {
                invoice = (int)command.ExecuteScalar() + 1;                                               //if not add one to the last invocie number as it is a new invoice
            }
            FindViewById <TextView>(Resource.Id.txtInvoiceNumberResult).Text = Convert.ToString(invoice); //this will display it in the textbox
            connection.Close();
            servicesList(spinner);                                                                        //get the service names from database to snipper
            var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, servicess);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinner.Adapter       = adapter;
            spinner.ItemSelected += Spinner_ItemSelected;//once something has been selected
        }