private void mtbDatumOsemenuvanje_Validating(object sender, CancelEventArgs e)
 {
     if (mtbDatumOsemenuvanje.Text.Trim().Length != 10)
     {
         errorProvider1.SetError(mtbDatumOsemenuvanje, "Внеси датум на осеменување");
         e.Cancel = true;
     }
     else
     {
         errorProvider1.SetError(mtbDatumOsemenuvanje, null);
         Osemenuvanje = MakeDate.makeDate(mtbDatumOsemenuvanje.Text);
         e.Cancel     = false;
     }
 }
 private void MTBDatum_Validating(object sender, CancelEventArgs e)
 {
     if (MTBDatum.Text.Trim().Length != 10)
     {
         errorProvider1.SetError(MTBDatum, "Внеси датум");
         e.Cancel = true;
     }
     else
     {
         errorProvider1.SetError(MTBDatum, null);
         OS.BirthDate = MakeDate.makeDate(MTBDatum.Text);;
         e.Cancel     = false;
     }
 }
 private void mtbDatum_Validating(object sender, CancelEventArgs e)
 {
     if (mtbDatum.Text.Trim().Length != 10)
     {
         errorProvider1.SetError(mtbDatum, "Внеси датум");
         e.Cancel = true;
     }
     else
     {
         errorProvider1.SetError(mtbDatum, null);
         Datum    = MakeDate.makeDate(mtbDatum.Text);
         Aktivno  = false;
         e.Cancel = false;
     }
 }
        private void buttonSave_Click(object sender, EventArgs e)
        {
            if ((cm1.Text.Trim().Length != 0 && numericUpDown1.Value != 0 && mbDatum1.Text.Trim().Length == 10) || (numericUpDown2.Value != 0 && mbDatum2.Text.Trim().Length == 10))
            {
                if (cbSkladiliste1.SelectedIndex != -1)
                {
                    if (cm1.SelectedIndex != -1)
                    {
                        if ((int)numericUpDown1.Value != 0)
                        {
                            if (mbDatum1.Text.Length == 10)
                            {
                                DA = new DataAcess();
                                if (cm1.SelectedItem.ToString().Equals("Купено") || cm1.SelectedItem.ToString().Equals("Родено"))
                                {
                                    SqlCommand cmd1 = new SqlCommand("Insert Into tblDvizenje(ID,Skladiste,VidDvizenje,Priem,Izdavanje,Datum)" +
                                                                     " Values(0,N'" + cbSkladiliste1.SelectedItem.ToString() + "',N'" + cm1.SelectedItem.ToString() + "',N'" + (int)numericUpDown1.Value + "', '0', cast('" + MakeDate.makeDate(mbDatum1.Text) + "' as datetime))", DA.getConnection());
                                    DA.cmdCommand(cmd1);
                                    if (cbSkladiliste1.SelectedItem.ToString().Equals("Прасилиште"))
                                    {
                                        int tmp = int.Parse(textBox3.Text);
                                        textBox3.Text = (tmp + (int)numericUpDown1.Value).ToString();
                                        cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox3.Text) + "' where id = '1'", DA.getConnection());
                                        DA.cmdCommand(cmd1);
                                        Refresh();
                                    }
                                    else if (cbSkladiliste1.SelectedItem.ToString().Equals("Б-Фаза"))
                                    {
                                        int tmp = int.Parse(textBox4.Text);
                                        textBox4.Text = (tmp + (int)numericUpDown1.Value).ToString();
                                        cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox4.Text) + "' where id = '2'", DA.getConnection());
                                        DA.cmdCommand(cmd1);
                                        Refresh();
                                    }
                                    else
                                    {
                                        int tmp = int.Parse(textBox5.Text);
                                        textBox5.Text = (tmp + (int)numericUpDown1.Value).ToString();
                                        cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox5.Text) + "' where id = '3'", DA.getConnection());
                                        DA.cmdCommand(cmd1);
                                        Refresh();
                                    }
                                }
                                else
                                {
                                    SqlCommand cmd1 = new SqlCommand("Insert Into tblDvizenje(ID,Skladiste,VidDvizenje,Priem,Izdavanje,Datum) " +
                                                                     "Values(0,N'" + cbSkladiliste1.SelectedItem.ToString() + "',N'" + cm1.SelectedItem.ToString() + "', '0', N'" + (int)numericUpDown1.Value +
                                                                     "',cast('" + MakeDate.makeDate(mbDatum1.Text) + "' as datetime))", DA.getConnection());
                                    DA.cmdCommand(cmd1);
                                    if (cbSkladiliste1.SelectedItem.ToString().Equals("Прасилиште"))
                                    {
                                        int tmp = int.Parse(textBox3.Text);
                                        textBox3.Text = (tmp - (int)numericUpDown1.Value).ToString();
                                        cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox3.Text) + "' where id = '1'", DA.getConnection());
                                        DA.cmdCommand(cmd1);
                                        Refresh();
                                    }
                                    else if (cbSkladiliste1.SelectedItem.ToString().Equals("Б-Фаза"))
                                    {
                                        int tmp = int.Parse(textBox4.Text);
                                        textBox4.Text = (tmp - (int)numericUpDown1.Value).ToString();
                                        cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox4.Text) + "' where id = '2'", DA.getConnection());
                                        DA.cmdCommand(cmd1);
                                        Refresh();
                                    }
                                    else
                                    {
                                        int tmp = int.Parse(textBox5.Text);
                                        textBox5.Text = (tmp - (int)numericUpDown1.Value).ToString();
                                        cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox5.Text) + "' where id = '3'", DA.getConnection());
                                        DA.cmdCommand(cmd1);
                                        Refresh();
                                    }
                                }
                            }
                        }
                    }
                }
                else if (cbSkladiliste2.SelectedIndex != -1)
                {
                    if ((int)numericUpDown2.Value != 0)
                    {
                        if (mbDatum2.Text.Length == 10)
                        {
                            DataAcess DA = new DataAcess();
                            if (cbSkladiliste2.SelectedItem.ToString().Equals("Прасилиште - Б-Фаза"))
                            {
                                SqlCommand cmd1 = new SqlCommand("Insert Into tblDvizenje(ID,Skladiste,VidDvizenje,Priem, Izdavanje, Datum) " +
                                                                 "Values(0,N'Прасилиште', N'Пренос', '0', N'" + (int)numericUpDown2.Value +
                                                                 "', cast('" + MakeDate.makeDate(mbDatum2.Text) + "' as datetime))", DA.getConnection());
                                DA.cmdCommand(cmd1);

                                int tmp = int.Parse(textBox3.Text);
                                textBox3.Text = (tmp - (int)numericUpDown2.Value).ToString();
                                cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox3.Text) + "' where id = '1'", DA.getConnection());
                                DA.cmdCommand(cmd1);

                                cmd1 = new SqlCommand("Insert Into tblDvizenje(ID,Skladiste,VidDvizenje,Priem, Izdavanje,Datum) " +
                                                      "Values(0,N'Б-Фаза', N'Пренос', N'" + (int)numericUpDown2.Value +
                                                      "', '0', cast('" + MakeDate.makeDate(mbDatum2.Text) + "' as datetime))", DA.getConnection());
                                DA.cmdCommand(cmd1);

                                tmp           = int.Parse(textBox4.Text);
                                textBox4.Text = (tmp + (int)numericUpDown2.Value).ToString();
                                cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox4.Text) + "' where id = '2'", DA.getConnection());
                                DA.cmdCommand(cmd1);

                                Refresh();
                            }
                            else
                            {
                                SqlCommand cmd1 = new SqlCommand("Insert Into tblDvizenje(ID,Skladiste,VidDvizenje,Priem,Izdavanje,Datum) " +
                                                                 "Values(0,N'Б-Фаза', N'Пренос', '0', N'" + (int)numericUpDown2.Value +
                                                                 "', cast('" + MakeDate.makeDate(mbDatum2.Text) + "' as datetime))", DA.getConnection());
                                DA.cmdCommand(cmd1);

                                int tmp = int.Parse(textBox4.Text);
                                textBox4.Text = (tmp - (int)numericUpDown2.Value).ToString();
                                cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox4.Text) + "' where id = '2'", DA.getConnection());
                                DA.cmdCommand(cmd1);

                                cmd1 = new SqlCommand("Insert Into tblDvizenje(ID,Skladiste,VidDvizenje,Priem,Izdavanje,Datum) " +
                                                      "Values(0,N'Товилиште', N'Пренос', N'" + (int)numericUpDown2.Value +
                                                      "', '0', cast('" + MakeDate.makeDate(mbDatum2.Text) + "' as datetime))", DA.getConnection());
                                DA.cmdCommand(cmd1);

                                tmp           = int.Parse(textBox5.Text);
                                textBox5.Text = (tmp + (int)numericUpDown2.Value).ToString();
                                cmd1          = new SqlCommand("Update tblDvizenje set Priem = '" + int.Parse(textBox5.Text) + "' where id = '3'", DA.getConnection());
                                DA.cmdCommand(cmd1);

                                Refresh();
                            }
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("Внеси ги потребните податоци!");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            DataAcess DA = new DataAcess();

            if (mtbDatumKontrola.Enabled)
            {
                SqlCommand cmd1 = new SqlCommand("UPDATE tblReprodukcija SET KontrolaDatum = cast('" + MakeDate.makeDate(mtbDatumKontrola.Text) + "' as datetime)  Where FMajka = N'" + tbZensko.Text + "' and MTatko = N'" + tbMasko.Text + "'and OsemenuvanjeDatum = cast('" + tbDatumOsemenuvanje.Text + "' as datetime)", DA.getConnection());
                DA.cmdCommand(cmd1);
                if (comboBox1.SelectedItem.Equals("Да"))
                {
                    cmd1 = new SqlCommand("UPDATE tblReprodukcija SET Kontrola = '1' Where FMajka = N'" + tbZensko.Text + "' and MTatko = N'" + tbMasko.Text + "'and OsemenuvanjeDatum = cast('" + tbDatumOsemenuvanje.Text + "' as datetime)", DA.getConnection());
                    DA.cmdCommand(cmd1);
                }
            }
            if (mtbDatumOprasuvanje.Enabled)
            {
                SqlCommand cmd1 = new SqlCommand("UPDATE tblReprodukcija SET OprasuvanjeDatum = cast('" + MakeDate.makeDate(mtbDatumOprasuvanje.Text) + "' as datetime) Where FMajka = N'" + tbZensko.Text + "' and MTatko = N'" + tbMasko.Text + "'and OsemenuvanjeDatum = cast('" + tbDatumOsemenuvanje.Text + "' as datetime)", DA.getConnection());
                DA.cmdCommand(cmd1);
                cmd1 = new SqlCommand("UPDATE tblReprodukcija SET ZivoRodeniPrasinja = '" + (int)numericUpDown1.Value + "',MrtvoRodeniPrasinja = N'" + (int)numericUpDown2.Value + "',NevitalniPrasinja = N'" + (int)numericUpDown3.Value + "' Where FMajka = N'" + tbZensko.Text + "' and MTatko = N'" + tbMasko.Text + "'and OsemenuvanjeDatum = cast('" + tbDatumOsemenuvanje.Text + "' as datetime)", DA.getConnection());
                DA.cmdCommand(cmd1);
            }
            if (mtbDatumOdbivanje.Enabled)
            {
                SqlCommand cmd1 = new SqlCommand("UPDATE tblReprodukcija SET OdbivanjeDatum = cast('" + MakeDate.makeDate(mtbDatumOdbivanje.Text) + "' as datetime) Where FMajka = N'" + tbZensko.Text + "' and MTatko = N'" + tbMasko.Text + "'and OsemenuvanjeDatum = cast('" + tbDatumOsemenuvanje.Text + "' as datetime)", DA.getConnection());
                DA.cmdCommand(cmd1);
                cmd1 = new SqlCommand("UPDATE tblReprodukcija SET OdbieniPrasinja = '" + (int)numericUpDown4.Value + "',MrtvoRodeniPrasinja = N'" + (int)numericUpDown2.Value + "',NevitalniPrasinja = N'" + (int)numericUpDown3.Value + "' Where FMajka = N'" + tbZensko.Text + "' and MTatko = N'" + tbMasko.Text + "'and OsemenuvanjeDatum = cast('" + tbDatumOsemenuvanje.Text + "' as datetime)", DA.getConnection());
                DA.cmdCommand(cmd1);
            }
            DialogResult = DialogResult.Yes;
        }