Esempio n. 1
0
        public Boolean add()
        {
            string qryStringMember;

            qryStringMember = "Insert into tbl_item (item_id, item_name, category, model, brand, selling_price, wholesale_price, description, item_note, date_added, supplier_id) VALUES (@item_id, @item_name, @category, @model, @brand, @selling_price, @wholesale_price, @description, @item_note, NOW(), @supplier_id)";

            try
            {
                Connect.CnSql = new MySqlConnection(Connect.ConnStr);
                Connect.CnSql.Open(); Connect.CmSql = new MySqlCommand(qryStringMember, Connect.CnSql);
                Connect.CmSql.Parameters.AddWithValue("@item_id", ItemId.Trim());
                Connect.CmSql.Parameters.AddWithValue("@item_name", ItemName.Trim());
                Connect.CmSql.Parameters.AddWithValue("@category", Category.Trim());
                Connect.CmSql.Parameters.AddWithValue("@model", Model.Trim());
                Connect.CmSql.Parameters.AddWithValue("@brand", Brand.Trim());
                Connect.CmSql.Parameters.AddWithValue("@selling_price", SellingPrice);
                Connect.CmSql.Parameters.AddWithValue("@wholesale_price", WholesalePrice);
                Connect.CmSql.Parameters.AddWithValue("@description", Description.Trim());
                Connect.CmSql.Parameters.AddWithValue("@item_note", ItemNote.Trim());
                Connect.CmSql.Parameters.AddWithValue("@supplier_id", SupplierId);

                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_item_sales (item_id, sold_quantity, discount, date_purchased, tranx_no, user_id) VALUES (@item_id, @sold_quantity, @discount, NOW(), @tranx_no, @user_id)";

            try
            {
                Connect.CnSql = new MySqlConnection(Connect.ConnStr);
                Connect.CnSql.Open(); Connect.CmSql = new MySqlCommand(qryStringMember, Connect.CnSql);
                Connect.CmSql.Parameters.AddWithValue("@item_id", ItemId.Trim());
                Connect.CmSql.Parameters.AddWithValue("@sold_quantity", SoldQuantity.Trim());
                Connect.CmSql.Parameters.AddWithValue("@discount", Discount);
                Connect.CmSql.Parameters.AddWithValue("@tranx_no", TranxNo.Trim());
                Connect.CmSql.Parameters.AddWithValue("@user_id", UserId);


                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_defective_items (item_id, no_of_defective_item, item_issue, user_id, date_added) VALUES (@item_id, @no_of_defective_item, @item_issue, @user_id, NOW())";

            try
            {
                Connect.CnSql = new MySqlConnection(Connect.ConnStr);
                Connect.CnSql.Open(); Connect.CmSql = new MySqlCommand(qryStringMember, Connect.CnSql);
                Connect.CmSql.Parameters.AddWithValue("@item_id", ItemId.Trim());
                Connect.CmSql.Parameters.AddWithValue("@no_of_defective_item", NoOfDefectiveItem);
                Connect.CmSql.Parameters.AddWithValue("@item_issue", ItemIssue.Trim());
                Connect.CmSql.Parameters.AddWithValue("@user_id", UserId);

                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);
        }