private void ShipOrderbtn_Click(object sender, EventArgs e) { ShipmentR i = new ShipmentR(); i.OrderId = this.orderIdTxt.Text; i.ShipmentProgress = 0; i.Status = ""; ShipmentRepository shipRepo = new ShipmentRepository(); //insert into shipment table if the product is sufficient in inventory if (Convert.ToInt32(this.quantityTxt.Text) <= Convert.ToInt32(this.textBox7.Text)) { if (shipRepo.Insert(i)) { //---------------update the volume in inventory after successful shipment-----------------// int latestVolume = Convert.ToInt32(this.textBox7.Text) - Convert.ToInt32(this.quantityTxt.Text); InventoryRepository ir = new InventoryRepository(); if (ir.updateInventory(this.productIdTxt.Text, latestVolume)) { MessageBox.Show("One Row Updated in Inventory"); } else { MessageBox.Show("Can't update inventory", "Update Error"); } //---------------Update and hide From Order Tabel after Shipment-----------------// OrderRepository or = new OrderRepository(); if (or.updateStatus(this.orderIdTxt.Text)) { MessageBox.Show("Order Updated"); } else { MessageBox.Show("unSuccessfull order update", "Update Error"); } MessageBox.Show("Succsfull ", "Shipment"); //---------------refresh the order Grid-----------------// List <OrderR> order = new List <OrderR>(); order = or.GetAllOrder(); this.dataGrid2.DataSource = order; this.orderIdTxt.Text = ""; this.productIdTxt.Text = ""; this.productNameTxt.Text = ""; this.quantityTxt.Text = ""; this.addressTxt.Text = ""; this.employeeNameTxt.Text = ""; } else { MessageBox.Show("Can Not Ship Order", "Ship Error"); } } else { MessageBox.Show("Unsufficient amount of Product", "Available Error"); } }