private void authadd_Click(object sender, EventArgs e)
        {
            AUTHOR a = new AUTHOR();

            a.Author_ID   = Convert.ToInt32(auth_id.Text);
            a.Author_Name = auth_name.Text;
            using (DataClasses1DataContext context = new DataClasses1DataContext())
            {
                context.AUTHORs.InsertOnSubmit(a);
                context.SubmitChanges();
            }
        }
 private void pubadd_Click(object sender, EventArgs e)
 {
     try{
         bool   flag = false;
         AUTHOR a    = new AUTHOR();
         a.Author_ID   = Convert.ToInt32(authoridbox.Text);
         a.Author_Name = authornamebox.Text;
         using (DataClasses1DataContext context = new DataClasses1DataContext())
         {
             foreach (AUTHOR a1 in context.AUTHORs)
             {
                 if ((a1.Author_ID == a.Author_ID || a1.Author_Name == a.Author_Name) && !string.IsNullOrEmpty(authornamebox.Text))
                 {
                     flag = true;
                 }
             }
             if (flag == false)
             {
                 context.AUTHORs.InsertOnSubmit(a);
                 context.SubmitChanges();
                 MessageBox.Show("Author Added successfully.");
             }
             else if (string.IsNullOrEmpty(authornamebox.Text))
             {
                 MessageBox.Show("adsd");
             }
             else
             {
                 MessageBox.Show("Same Id/Name found.");
             }
         }
     }
     catch (FormatException)
     {
         MessageBox.Show("Input Error.");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
示例#3
0
 partial void DeleteAUTHOR(AUTHOR instance);
示例#4
0
 partial void UpdateAUTHOR(AUTHOR instance);
示例#5
0
 partial void InsertAUTHOR(AUTHOR instance);