예제 #1
0
        public void SaveAssessment(Assessment1 inputModel)
        {
            //Save to DB
            using (var con = new SqlConnection(connString))
            {
                con.Open();

                using (var cmd = new SqlCommand())
                {
                    cmd.Connection     = con;
                    cmd.CommandType    = CommandType.StoredProcedure;
                    cmd.CommandText    = "SaveAssessment";
                    cmd.CommandTimeout = 1000;
                    cmd.Parameters.Add(new SqlParameter("@firstname", inputModel.firstname));
                    cmd.Parameters.Add(new SqlParameter("@lastname", inputModel.lastname));
                    cmd.Parameters.Add(new SqlParameter("@hiredate", inputModel.hiredate));
                    cmd.Parameters.Add(new SqlParameter("@email", inputModel.email));
                    cmd.Parameters.Add(new SqlParameter("@country", inputModel.country));
                    cmd.Parameters.Add(new SqlParameter("@gender", inputModel.gender));
                    cmd.Parameters.Add(new SqlParameter("@tech", inputModel.technologies));
                    cmd.Parameters.Add(new SqlParameter("@qual", inputModel.qualification));
                    var count = cmd.ExecuteNonQuery();
                }
                con.Close();
            }
        }
예제 #2
0
 public void SaveAssessmentEF(Assessment1 inputModel)
 {
     using (var context = new sampleDBEntities1())
     {
         var assessment = new Assessment()
         {
             FirstName = inputModel.firstname,
             LastName  = inputModel.lastname,
             Email     = inputModel.email,
             Country   = inputModel.country,
             Gender    = inputModel.gender,
             HireDate  = inputModel.hiredate
         };
         context.Assessments.Add(assessment);
         context.SaveChanges();
     }
 }
예제 #3
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string tech = string.Empty;
            string qual = string.Empty;

            foreach (ListItem item in chkTech.Items)
            {
                if (item.Selected)
                {
                    tech += item.Text + "|";
                }
            }
            int lastindextech = tech.LastIndexOf("|");//to remove last |

            tech = tech.Remove(lastindextech);
            foreach (ListItem item in lstQualification.Items)
            {
                if (item.Selected)
                {
                    qual += item.Text + "|";
                }
            }
            int lastindexqual = qual.LastIndexOf("|");

            qual = qual.Remove(lastindexqual);

            var inputModel = new Assessment1()
            {
                firstname     = txtFirstName.Text,
                lastname      = txtLastName.Text,
                email         = txtEmail.Text,
                hiredate      = Convert.ToDateTime(txtHireDate.Text),
                gender        = Convert.ToInt32(rbtnGenderList.SelectedValue),
                country       = ddlCountry.SelectedValue,
                technologies  = tech,
                qualification = qual
            };

            var data = new DataAccess.AssessmentData();

            //data.SaveAssessment(inputModel);
            data.SaveAssessmentEF(inputModel);
            BindDataGrid();
        }