Пример #1
0
 public void AddNewItems()
 {
     DetermineItemStatus();
     try
     {
         if (LBName.Text != "")
         {
             if (LBTitle.Text == "Bicycle")
             {
                 PopulateBikeDataTable();
                 if (LBID.Text != null)
                 {
                     TBikeDAL      MyDAL = new TBikeDAL();
                     ConfirmWindow con   = new ConfirmWindow(ImageType.Question, "Are you sure to add new data?", "Confirmation", "Yes", "No");
                     con.ShowDialog();
                     if (con.Confirmed)
                     {
                         MyDAL.AddBicycleTable(TBName.Text, TBType.Text, Convert.ToInt32(TBQuantity.Text), Convert.ToDouble(TBPrice.Text), TBColor.Text, TLUsername.Text);
                         PopulateBikeDataTable();
                     }
                 }
             }
             else if (LBTitle.Text == "Snacks")
             {
                 PopulateSnackDataTable();
                 TBikeDAL      MyDAL = new TBikeDAL();
                 ConfirmWindow con   = new ConfirmWindow(ImageType.Question, "Confirmation", "Are you sure to add new data?", "Add Please", "No, don't add please");
                 con.ShowDialog();
                 if (con.Confirmed)
                 {
                     MyDAL.AddSnackTable(TBName.Text, TBType.Text, Convert.ToDouble(TBPrice.Text), Convert.ToInt32(TBColor.Text), TLUsername.Text);
                     PopulateSnackDataTable();
                 }
             }
         }
         else
         {
             PopWindow con = new PopWindow(ImageType.Error, "No field", "Please fill in all", "OK");
             con.ShowDialog();
         }
     }
     catch (Exception ex)
     {
         PopWindow pop = new PopWindow(ImageType.Information, "Error", ex.Message, "I will Fix this");
         pop.ShowDialog();
         pop.Dispose();
     }
 }