private void btn_update_Click(object sender, EventArgs e) { if (txt_item_ID.Text.Length == 0 && txt_batch_ID.Text.Length == 0 && txt_item_Name.Text.Length == 0) { MessageBox.Show("Please fill on of those text fields to complete the proccess", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { try { using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["cn"].ConnectionString)) { if (db.State == ConnectionState.Closed) { db.Open(); obj.itemID = v_itemId; obj.BatchID = txt_batch_ID.Text; obj.ItemName = txt_ItemName.Text; obj.ItemType = cmb_ItemType.SelectedItem.ToString(); obj.ItemDesc = txt_ItemDesc.Text; obj.DateTime = dtp_Date.Value.ToString(); obj.PurchasePrice = Convert.ToDouble(txt_purchasePrice.Text); obj.CashInWoleSale = Convert.ToDouble(txt_cashWholeSale.Text); obj.VatPercentage = Convert.ToDouble(txt_Vat.Text); obj.VatAmount = Convert.ToDouble(txt_taxAmt.Text); int resultIF = obj.update(); if (resultIF == 1) { MsgBox.Show(6); } } } } catch { throw; } } }