// Sql Server Connector
        // TODO - Make the CreateTaxiCentral method actually save to the database
        /// <summary>
        /// Saves a new Taxi central to the database
        /// </summary>
        /// <param name="model">The Taxi central information</param>
        /// <returns>The Taxi Central information, including the unique identifier.</returns>
        public TaxiCentralModel CreateTaxiCentral(TaxiCentralModel model)
        {
            using (IDbConnection connection = new Microsoft.Data.SqlClient.SqlConnection(
                       GlobalConfig.GetConnectionString("TDMSDatabase")))
            {
                var p = new DynamicParameters();
                p.Add("@Name", model.Name);
                p.Add("@Id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

                connection.Execute("dbo.spTaxiCentral_Insert", p, commandType: CommandType.StoredProcedure);

                model.Id = p.Get <int>("@Id");

                return(model);
            }
        }
        private void SaveButton_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                TaxiCentralModel model = new TaxiCentralModel(TaxiCentralNameTextBox.Text);


                GlobalConfig.Connection.CreateTaxiCentral(model);


                TaxiCentralNameTextBox.Text = "";
            }
            else
            {
                MessageBox.Show("This form has invalid information. Please check it and try again");
                DialogResult = DialogResult.None;
            }
        }
Exemple #3
0
 public TaxiCentralModel CreateTaxiCentral(TaxiCentralModel model)
 {
     throw new NotImplementedException();
 }