private void btnAdd_Click(object sender, EventArgs e)
 {
     pcredit = BuildObjedtByField();
     if (pcredit != null)
     {
         DataRow dr = pcredit.BuildRow();
         AddPointsCreditTable prodacts = new AddPointsCreditTable();
         if (prodacts.Add(dr) == false)
         {
             MessageBox.Show("קיים במאגר");
         }
         else
         {
             MessageBox.Show("התווסף בהצלחה");
         }
     }
 }
        public AddPointsCredit BuildObjedtByField()
        {
            errorProvider1.Clear();
            pcredit = new AddPointsCredit();
            bool ok = true;

            try
            {
                pcredit.CodeAddPoint = Convert.ToInt32(txtBcodeP.Text);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtBcodeP, ex.Message);
                ok = false;
            }

            try
            {
                pcredit.NumOfPoint = Convert.ToInt32(txtBNumP.Text);
            }
            catch (Exception ex)
            {
                errorProvider1.SetError(txtBNumP, ex.Message);
                ok = false;
            }


            pcredit.Status = true;


            if (ok)
            {
                return(pcredit);
            }
            return(null);
        }