private void Confirm_Click(object sender, EventArgs e)
 {
     if (textBox2.Text == "" || textBox4.Text == "" || textBox6.Text == "" || comboBox1.Text == "" || textBox3.Text == "")
     {
         MessageBox.Show("Error!Please fill the blanks with (*).");
     }
     else
     {
         context = new SA45Team13bLibraryEntities();
         int           i  = Int32.Parse(textBox1.Text);
         LibraryMember lb = new LibraryMember();
         lb = context.LibraryMembers.Where(x => x.CustomerID == i).First();
         lb.CustomerName   = textBox2.Text;
         lb.Age            = Int16.Parse(textBox3.Text);
         lb.Address        = textBox4.Text;
         lb.PostalCode     = textBox5.Text;
         lb.DocumentNo     = textBox6.Text;
         lb.DocumentType   = comboBox1.Text;
         lb.PhoneNumber    = textBox8.Text;
         lb.EmailAddress   = textBox9.Text;
         lb.AltPhoneNumber = textBox10.Text;
         context.SaveChanges();
         MessageBox.Show("Submit success!");
         this.Close();
     }
 }
 private void Confirm_Click_1(object sender, EventArgs e)
 {
     m       = new LibraryMember();
     context = new SA45Team13bLibraryEntities();
     if (CustomerNameBox.Text == "" || AddressBox.Text == "" || DocumentNoBox.Text == "" || DocumentTypeBox.Text == "" || AgeBox.Text == "")
     {
         MessageBox.Show("Error!Please fill the blanks with (*).");
     }
     else if (System.Text.RegularExpressions.Regex.IsMatch(AgeBox.Text, "[^0-9]"))
     {
         MessageBox.Show("Please enter correct age.");
     }
     else
     {
         m.CustomerName   = CustomerNameBox.Text;
         m.Age            = Int16.Parse(AgeBox.Text);
         m.Address        = AddressBox.Text;
         m.PostalCode     = PostalCodeBox.Text;
         m.DocumentNo     = DocumentNoBox.Text;
         m.DocumentType   = DocumentTypeBox.Text;
         m.PhoneNumber    = PhoneNumberBox.Text;
         m.EmailAddress   = EmailAddressBox.Text;
         m.AltPhoneNumber = AltPhoneNumberBox.Text;
         context.LibraryMembers.Add(m);
         context.SaveChanges();
         MessageBox.Show("Submit success!");
         Refresh();
         this.Close();
     }
 }
Ejemplo n.º 3
0
        private void Confirm_Click(object sender, EventArgs e)
        {
            m = new LibraryMember();
            using (TransactionScope ts = new TransactionScope())
            {
                context = new SA45Team13bLibraryEntities();

                m.CustomerName = textBox2.Text;
                var k = Int16.Parse(textBox3.Text);
                m.Age            = Int16.Parse(textBox3.Text);
                m.Address        = textBox4.Text;
                m.PostalCode     = textBox5.Text;
                m.DocumentNo     = textBox6.Text;
                m.DocumentType   = comboBox1.Text;
                m.PhoneNumber    = textBox8.Text;
                m.EmailAddress   = textBox9.Text;
                m.AltPhoneNumber = textBox10.Text;

                context.LibraryMember.Add(m);
                context.SaveChanges();
                ts.Complete();
                MessageBox.Show("Submit success!");
                this.Close();
            }
        }
Ejemplo n.º 4
0
        private void textBox1_TextChanged(object sender, EventArgs e) //CustomerID textBox changed
        {
            textBox2.Text = null;

            List <int> IDList = context.LibraryMembers.Select(x => x.CustomerID).ToList();

            foreach (int i in IDList)
            {
                if (i.ToString() == textBox1.Text)
                {
                    lM            = context.LibraryMembers.Where(x => x.CustomerID == i).First();
                    textBox2.Text = lM.CustomerName;
                }
            }
        }
        private void Delete_Click(object sender, System.EventArgs e)
        {
            if (dataGridView1.SelectedRows.Count != 0)
            {
                string        xx = dataGridView1.CurrentRow.Cells[1].Value.ToString();
                LibraryMember lb = context.LibraryMembers.Where(x => x.CustomerName == xx).First();
                context.LibraryMembers.Remove(lb);

                DialogResult result = MessageBox.Show("Are you sure to delete?", "Confirm", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    MessageBox.Show("Delete Success!");
                    context.SaveChanges();
                    refresh();
                }
            }
            else
            {
                MessageBox.Show("Please Search Member First");
                return;
            }
        }