Exemple #1
0
        /// <summary>
        /// Creates a Model of a bug based on what the user input into the forms
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void buttonCBCreate_Click(object sender, EventArgs e)
        {
            if (ValidateForm())
            {
                var model = new ModelBug
                {
                    BugProductName     = Globals.Product.ToString(),
                    BugDescription     = textBoxCreateBugDescription.Text,
                    BugText            = textBoxCreateBugText.Text,
                    BugReportedVersion = comboBoxCreateBug.Text,
                    BugWhenReported    = DateTime.Now,
                    BugFixed           = false
                };

                var da = new DataAccess();

                try
                {
                    da.CreateBug(model);
                }
                catch
                {
                    Console.WriteLine("what the f**k bro");
                }

                ClearTextBoxes();
            }
        }
Exemple #2
0
        public ModelBug CreateBug(ModelBug model)
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(ConnectionStringHelper.ConnectionValue("BugTracker")))
            {
                var p = new DynamicParameters();

                p.Add("@BugProductName", model.BugProductName);
                p.Add("@BugDescription", model.BugDescription);
                p.Add("@BugText", model.BugText);
                p.Add("@BugReportedVersion", model.BugReportedVersion);
                p.Add("@BugWhenReported", model.BugWhenReported);
                p.Add("@id", 0, dbType: DbType.Int32, direction: ParameterDirection.Output);

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

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

                return(model);
            }
        }