public Boolean update() { string qryStringMember; qryStringMember = "UPDATE tbl_order set " + "ordered_item=@ordered_item, " + "additional_info=@additional_info, " + "customer_name=@customer_name, contact_no=@contact_no, " + "downpayment=@downpayment, order_price=@order_price " + "WHERE order_id=@order_id"; try { Connect.CnSql = new MySqlConnection(Connect.ConnStr); Connect.CnSql = new MySqlConnection(Connect.ConnStr); Connect.CnSql.Open(); Connect.CmSql = new MySqlCommand(qryStringMember, Connect.CnSql); Connect.CmSql.Parameters.AddWithValue("@ordered_item", OrderItem.Trim()); Connect.CmSql.Parameters.AddWithValue("@additional_info", AdditionalInfo.Trim()); Connect.CmSql.Parameters.AddWithValue("@customer_name", CustomerName.Trim()); Connect.CmSql.Parameters.AddWithValue("@contact_no", ContactNo.Trim()); Connect.CmSql.Parameters.AddWithValue("@downpayment", Downpayment); Connect.CmSql.Parameters.AddWithValue("@order_price", OrderPrice); Connect.CmSql.Parameters.AddWithValue("@order_id", OrderId); Trans = Connect.CnSql.BeginTransaction(); Connect.CmSql.Transaction = Trans; Connect.CmSql.ExecuteNonQuery(); Trans.Commit(); return(true); } catch (MySqlException e) { XtraMessageBox.Show(e.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); Trans.Rollback(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "General Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); Trans.Rollback(); } finally { Connect.CnSql.Close(); Connect.CnSql.Dispose(); Connect.CmSql.Dispose(); Connect.CmSql = null; Connect.DrSql = null; } return(false); }
public Boolean add() { string qryStringMember; qryStringMember = "Insert into tbl_order (ordered_item, additional_info, customer_name, contact_no, downpayment, order_price, status, store_representative, date_ordered) VALUES (@ordered_item, @additional_info, @customer_name, @contact_no, @downpayment, @order_price, @status, @store_representative, NOW())"; try { Connect.CnSql = new MySqlConnection(Connect.ConnStr); Connect.CnSql.Open(); Connect.CmSql = new MySqlCommand(qryStringMember, Connect.CnSql); Connect.CmSql.Parameters.AddWithValue("@ordered_item", OrderItem.Trim()); Connect.CmSql.Parameters.AddWithValue("@additional_info", AdditionalInfo.Trim()); Connect.CmSql.Parameters.AddWithValue("@customer_name", CustomerName.Trim()); Connect.CmSql.Parameters.AddWithValue("@contact_no", ContactNo.Trim()); Connect.CmSql.Parameters.AddWithValue("@downpayment", Downpayment); Connect.CmSql.Parameters.AddWithValue("@order_price", OrderPrice); Connect.CmSql.Parameters.AddWithValue("@status", Status); Connect.CmSql.Parameters.AddWithValue("@store_representative", StoreRepresentative.Trim()); Trans = Connect.CnSql.BeginTransaction(); Connect.CmSql.Transaction = Trans; Connect.CmSql.ExecuteNonQuery(); Trans.Commit(); return(true); } catch (MySqlException e) { XtraMessageBox.Show(e.Message, "SQL Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); Trans.Rollback(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message, "General Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); Trans.Rollback(); } finally { Connect.CnSql.Close(); Connect.CnSql.Dispose(); Connect.CmSql.Dispose(); Connect.CmSql = null; Connect.DrSql = null; } return(false); }