示例#1
0
        public static void InsertProfile(Profile profile)
        {
            string sql = "insert into Profiles " +
                "(FullName, BirthDate, BirthPlace, PassportData, " +
                " PersonalQualities, Characteristics, EntryDate) " +
                "values (@FullName, @BirthDate, @BirthPlace, @PassportData," +
                " @PersonalQualities, @Characteristics, @EntryDate)";

            Dictionary<string, object> parameters = new Dictionary<string, object>();

            parameters.Add("@FullName", profile.FullName);
            parameters.Add("@BirthDate", profile.BirthDate);
            parameters.Add("@BirthPlace", profile.BirthPlace);
            parameters.Add("@PassportData", profile.PassportData);
            parameters.Add("@PersonalQualities", profile.PersonalQualities);
            parameters.Add("@Characteristics", profile.Characteristics);
            parameters.Add("@EntryDate", profile.EntryDate);

            QueryWParams(sql, parameters, false);
        }
示例#2
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            int index = profileDataGridView.SelectedCells[0].RowIndex;
            DataRow row = ((DataTable)profileDataGridView.DataSource).Rows[index];
            Profile profile = new Profile(row);

            PersonForm pForm = new PersonForm(profile);
            pForm.Show();
            pForm.updateDGW += this.updateDGVfromDb;
        }
示例#3
0
        static void InsertProfile(Profile profile, SqlCeConnection cn)
        {
            SqlCeCommand cmd;
            string sql = "insert into Profiles " +
                "(FullName, BirthDate, BirthPlace, PassportData, " +
                " PersonalQualities, Characteristics, EntryDate) " +
                "values (@FullName, @BirthDate, @BirthPlace, @PassportData," +
                " @PersonalQualities, @Characteristics, @EntryDate)";

            try
            {
                cmd = new SqlCeCommand(sql, cn);
                cmd.Parameters.AddWithValue("@FullName", profile.FullName);
                cmd.Parameters.AddWithValue("@BirthDate", profile.BirthDate);
                cmd.Parameters.AddWithValue("@BirthPlace", profile.BirthPlace);
                cmd.Parameters.AddWithValue("@PassportData", profile.PassportData);
                cmd.Parameters.AddWithValue("@PersonalQualities", profile.PersonalQualities);
                cmd.Parameters.AddWithValue("@Characteristics", profile.Characteristics);
                cmd.Parameters.AddWithValue("@EntryDate", profile.EntryDate);
                cmd.ExecuteNonQuery();
            }
            catch (SqlCeException sqlexception)
            {
                MessageBox.Show(sqlexception.Message, "Sql Exception"
                  , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Exception"
                  , MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#4
0
        public static void UpdateProfile(Profile profile)
        {
            string sql = "UPDATE Profiles SET FullName = @FullName, BirthDate = @BirthDate, " +
               "BirthPlace = @BirthPlace, PassportData = @PassportData, PersonalQualities = @PersonalQualities, " +
               "Characteristics = @Characteristics WHERE Id = @Id";
            Dictionary<string, object> parameters = new Dictionary<string, object>();

            parameters.Add("@FullName", profile.FullName);
            parameters.Add("@BirthDate", profile.BirthDate);
            parameters.Add("@BirthPlace", profile.BirthPlace);
            parameters.Add("@PassportData", profile.PassportData);
            parameters.Add("@PersonalQualities", profile.PersonalQualities);
            parameters.Add("@Characteristics", profile.Characteristics);
            parameters.Add("@Id", profile.Id);

            QueryWParams(sql, parameters, false);
        }
示例#5
0
        static List<Profile> GenerateProfiles()
        {
            int profsNum = 100;
            Random r = new Random();
            List<Profile> profiles = new List<Profile>();

            for (int i = 0; i < profsNum; i++)
            {
                Profile profile = new Profile();
                profile.FullName = GenerateFullname(r);
                profile.BirthDate = GenerateBirthDay(r);
                profile.BirthPlace = GenerateBirthPlace(r);
                profile.PassportData = GeneratePassportData(r, profile.BirthDate);
                profile.PersonalQualities = GeneratePersonalQualities(r);
                profile.Characteristics = GenerateCharacteristics(r);
                profile.EntryDate = GenerateEntryDate(r);

                profiles.Add(profile);
            }

            return profiles;
        }