Пример #1
0
        // to delete data of selected row
        private void deleteRecord_Click1(object sender, RoutedEventArgs e)
        {
            int row;

            dc = new DataClasses1DataContext();
            InsertStock ins = new InsertStock();

            ins = mygridview2.SelectedItem as InsertStock;
            row = Convert.ToInt32(ins.Id);

            if (MessageBox.Show("Do you want to delete data?",
                                "Confirmation", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
            {
            }
            else
            {
                // Do not close the window
            }
            var selectQuery = from rows in dc.InsertStocks where rows.Id == row select rows;

            foreach (var c in selectQuery)
            {
                dc.InsertStocks.DeleteOnSubmit(c);
                dc.SubmitChanges();
            }
            MessageBox.Show("Data Deleted Successfully!!");
            mygridview2.ItemsSource = dc.InsertStocks;
        }
Пример #2
0
 //calling submit button function
 public void InsertStock()
 {
     //check if user input null value
     if (stockId.Text.Length == 0)
     {
         errorid.Text = "Enter stock Id.";
         stockId.Focus();
     }
     else if (itemType.Text.Length == 0)
     {
         errortype.Text = "Enter an item type.";
         itemType.Focus();
     }
     else if (itemname.Text.Length == 0)
     {
         errortype.Text = "Enter an item name.";
         itemname.Focus();
     }
     else if (itemQuantity.Text.Length == 0)
     {
         errorquantity.Text = "Enter an item type.";
         itemQuantity.Focus();
     }
     else if (shipmentReceived.Text.Length == 0)
     {
         errorshipment.Text = "Enter an item shipment d.";
         shipmentReceived.Focus();
     }
     else if (dealerName.Text.Length == 0)
     {
         errordname.Text = "Enter a dealer name.";
         dealerName.Focus();
     }
     else if (dealerEmail.Text.Length == 0)
     {
         errordemail.Text = "Enter an valid email.";
         dealerEmail.Focus();
     }
     else if (dealerPhoneNo.Text.Length == 0)
     {
         errorphone.Text = "Enter phone number .";
         dealerPhoneNo.Focus();
     }
     // validate null value before insertion of data
     if (stockId.Text.Length != 0 && itemType.Text.Length != 0 && itemname.Text.Length != 0 && shipmentReceived.Text.Length != 0 && dealerEmail.Text.Length != 0 && dealerName.Text.Length != 0 && dealerPhoneNo.Text.Length != 0)
     {
         dc = new DataClasses1DataContext();
         InsertStock add = new InsertStock();
         add.itemNumber       = Convert.ToInt32(stockId.Text);
         add.itemType         = itemType.Text;
         add.itemName         = itemname.Text;
         add.itemQuantity     = itemQuantity.Text;
         add.shipmentRecieved = shipmentReceived.Text;
         add.dName            = dealerName.Text;
         add.dEmail           = dealerEmail.Text;
         add.dPhone           = dealerPhoneNo.Text;
         dc.InsertStocks.InsertOnSubmit(add);
         dc.SubmitChanges();
         MessageBox.Show("Data Saved Successfully!!");
         stockId.Text          = "";
         itemType.Text         = "";
         itemname.Text         = "";
         shipmentReceived.Text = "";
         itemQuantity.Text     = "";
         dealerName.Text       = "";
         dealerEmail.Text      = "";
         dealerPhoneNo.Text    = "";
     }
 }
Пример #3
0
 partial void UpdateInsertStock(InsertStock instance);
Пример #4
0
 partial void DeleteInsertStock(InsertStock instance);
Пример #5
0
 partial void InsertInsertStock(InsertStock instance);