示例#1
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (Photo.Text.Length == 0 || EstimatedValue.Text.Length == 0 || textBox1.Text.Length == 0 || Discription.Text.Length == 0 || textBox2.Text.Length == 0 || textBox4.Text.Length == 0 || textBox5.Text.Length == 0 || textBox7.Text.Length == 0 || textBox8.Text.Length == 0)
     {
         MessageBox.Show("please fill all the form");
     }
     else
     {
         musueem.AddExhibit(textBox4.Text, dateTimePicker1.Value.ToString("yyyy-MM-dd"), EstimatedValue.Text, textBox1.Text, "9", Discription.Text, Photo.Text);
         int check = musueem.addsculpt(textBox1.Text, textBox4.Text, textBox7.Text, textBox2.Text, textBox5.Text, textBox8.Text);
         if (check == 0)
         {
             MessageBox.Show("error has occured");
         }
         else
         {
             MessageBox.Show("the sculpture has been added sucessfully");
             comboBox1.DataSource     = musueem.getallsclupt();
             comboBox1.DisplayMember  = "SerialNumber";
             comboBox1.ValueMember    = "SerialNumber";
             dataGridView1.DataSource = musueem.getallscluptwithsn(comboBox1.SelectedValue.ToString());
             comboBox2.DataSource     = musueem.getallsclupt();
             comboBox2.DisplayMember  = "SerialNumber";
             comboBox2.ValueMember    = "SerialNumber";
             dataGridView2.DataSource = musueem.getallscluptwithsn(comboBox2.SelectedValue.ToString());
         }
     }
 }
        private void button2_Click(object sender, EventArgs e)
        {
            //Checks if there is an empty textbox
            if (textBox7.Text == "" || textBox4.Text == "" || textBox2.Text == "" || textBox1.Text == "" || textBox5.Text == "" || textBox11.Text == "" || textBox9.Text == "" || textBox3.Text == "" || textBox6.Text == "" || textBox20.Text == "")
            {
                MessageBox.Show("Please Enter all the data required");
                return;
            }

            //Checks that the SerialNumber is not taken
            DataTable checktable = MuseumController.GetExhibitBySerialNumber(textBox5.Text);

            if (checktable != null)
            {
                MessageBox.Show("Serial Number is already taken");
                return;
            }

            //Adds the Jewelery
            int check;

            check = MuseumController.AddExhibit(textBox11.Text, dateTimePicker2.Value.ToString("yyyy-MM-dd"), textBox9.Text, textBox5.Text, label33.Text, textBox6.Text, textBox3.Text);
            if (check == 0)
            {
                MessageBox.Show("Failed to add fossil");
                return;
            }
            check = MuseumController.addfossils(textBox5.Text, textBox7.Text, textBox4.Text, textBox2.Text, textBox1.Text, textBox20.Text);
            if (check == 0)
            {
                MessageBox.Show("Failed to add fossil");
                return;
            }

            MessageBox.Show("Added Successfully");
        }