Exemple #1
0
        public GordenItem(Guid id)
        {
            ID = id;
            DataRow row = get(ID);

            Name                   = DBUtil.parseData <string>(row, COL_DB_NAME);
            CategoryEnumID         = Tools.parseEnum <GordenItemCategories>(DBUtil.parseData <int>(row, COL_DB_CATEGORYENUMID));
            VendorID               = DBUtil.parseData <Guid>(row, COL_DB_VENDORID);
            ProductWidthID         = DBUtil.parseData <Guid?>(row, COL_DB_PRODUCTWIDTHID);
            RetailLengthUnitID     = DBUtil.parseData <Guid>(row, COL_DB_RETAILLENGTHUNITID);
            BulkLengthUnitID       = DBUtil.parseData <Guid>(row, COL_DB_BULKLENGTHUNITID);
            BuyRetailPricePerUnit  = DBUtil.parseData <decimal>(row, COL_DB_BUYRETAILPRICEPERUNIT);
            BuyBulkPricePerUnit    = DBUtil.parseData <decimal>(row, COL_DB_BUYBULKPRICEPERUNIT);
            SellRetailPricePerUnit = DBUtil.parseData <decimal>(row, COL_DB_SELLRETAILPRICEPERUNIT);
            SellBulkPricePerUnit   = DBUtil.parseData <decimal>(row, COL_DB_SELLBULKPRICEPERUNIT);
            Active                 = DBUtil.parseData <bool>(row, COL_DB_ACTIVE);
            Notes                  = DBUtil.parseData <string>(row, COL_DB_NOTES);

            CategoryName         = DBUtil.parseData <string>(row, COL_CATEGORYNAME);
            VendorName           = DBUtil.parseData <string>(row, COL_VENDORNAME);
            RetailLengthUnitName = DBUtil.parseData <string>(row, COL_RETAILLENGTHUNITNAME);
            BulkLengthUnitName   = DBUtil.parseData <string>(row, COL_BULKLENGTHUNITNAME);
            ProductWidthName     = DBUtil.parseData <string>(row, COL_PRODUCTWIDTHNAME);
            ProductWidthInMeter  = DBUtil.parseData <decimal>(row, COL_PRODUCTWIDTHINMETER);
            Notes = DBUtil.parseData <string>(row, COL_DB_NOTES);
        }
Exemple #2
0
        public static void add(string name, GordenItemCategories category, Guid vendorID, Guid retailLengthUnitID, Guid bulkLengthUnitID, Guid?productWidthID, decimal buyRetailPricePerUnit, decimal buyBulkPricePerUnit,
                               decimal sellRetailPricePerUnit, decimal sellBulkPricePerUnit, string notes)
        {
            try
            {
                Guid id = Guid.NewGuid();
                using (SqlCommand cmd = new SqlCommand("gordenitem_add", DBConnection.ActiveSqlConnection))
                {
                    cmd.CommandType = CommandType.StoredProcedure;
                    cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value                 = id;
                    cmd.Parameters.Add("@" + COL_DB_NAME, SqlDbType.VarChar).Value                        = name;
                    cmd.Parameters.Add("@" + COL_DB_CATEGORYENUMID, SqlDbType.TinyInt).Value              = category;
                    cmd.Parameters.Add("@" + COL_DB_VENDORID, SqlDbType.UniqueIdentifier).Value           = vendorID;
                    cmd.Parameters.Add("@" + COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier).Value     = Util.wrapNullable(productWidthID);
                    cmd.Parameters.Add("@" + COL_DB_RETAILLENGTHUNITID, SqlDbType.UniqueIdentifier).Value = retailLengthUnitID;
                    cmd.Parameters.Add("@" + COL_DB_BULKLENGTHUNITID, SqlDbType.UniqueIdentifier).Value   = bulkLengthUnitID;
                    cmd.Parameters.Add("@" + COL_DB_BUYRETAILPRICEPERUNIT, SqlDbType.Decimal).Value       = Util.wrapNullable(buyRetailPricePerUnit);
                    cmd.Parameters.Add("@" + COL_DB_BUYBULKPRICEPERUNIT, SqlDbType.Decimal).Value         = Util.wrapNullable(buyBulkPricePerUnit);
                    cmd.Parameters.Add("@" + COL_DB_SELLRETAILPRICEPERUNIT, SqlDbType.Decimal).Value      = Util.wrapNullable(sellRetailPricePerUnit);
                    cmd.Parameters.Add("@" + COL_DB_SELLBULKPRICEPERUNIT, SqlDbType.Decimal).Value        = Util.wrapNullable(sellBulkPricePerUnit);
                    cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value                       = Util.wrapNullable(notes);

                    cmd.ExecuteNonQuery();


                    ActivityLog.submit(id, "Item created");
                }
                Tools.hasMessage("Item created");
            }
            catch (Exception ex) { Tools.showError(ex.Message); }
        }
Exemple #3
0
        public static void update(Guid id, string name, GordenItemCategories category, Guid vendorID, Guid retailLengthUnitID, Guid bulkLengthUnitID,
                                  Guid?productWidthID, decimal?buyRetailPricePerUnit, decimal?buyBulkPricePerUnit, decimal?sellRetailPricePerUnit, decimal?sellBulkPricePerUnit, string notes)
        {
            try
            {
                GordenItem objOld = new GordenItem(id);

                //generate log description
                string log = "";
                log = ActivityLog.appendChange(log, objOld.Name, name, "Name: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.CategoryName, category, "Category: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.VendorID, new Vendor(vendorID).Name, "Vendor: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.ProductWidthID, new ProductWidth(productWidthID).Name, "Width: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.RetailLengthUnitID, new LengthUnit(retailLengthUnitID).Name, "Retail Unit: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.BulkLengthUnitID, new LengthUnit(bulkLengthUnitID).Name, "Bulk Unit: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.BuyRetailPricePerUnit, buyRetailPricePerUnit, "Buy Retail Price/Unit: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.BuyBulkPricePerUnit, buyBulkPricePerUnit, "Buy Bulk Price/Unit: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.SellRetailPricePerUnit, sellRetailPricePerUnit, "Sell Retail Price/Unit: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.SellBulkPricePerUnit, sellBulkPricePerUnit, "Sell Bulk Price/Unit: '{0}' to '{1}'");
                log = ActivityLog.appendChange(log, objOld.Notes, notes, "Notes: '{0}' to '{1}'");

                if (string.IsNullOrEmpty(log))
                {
                    Tools.showError("No changes to record");
                }
                else
                {
                    using (SqlCommand cmd = new SqlCommand("gordenitem_update", DBConnection.ActiveSqlConnection))
                    {
                        cmd.CommandType = CommandType.StoredProcedure;
                        cmd.Parameters.Add("@" + COL_DB_ID, SqlDbType.UniqueIdentifier).Value                 = id;
                        cmd.Parameters.Add("@" + COL_DB_NAME, SqlDbType.VarChar).Value                        = name;
                        cmd.Parameters.Add("@" + COL_DB_CATEGORYENUMID, SqlDbType.TinyInt).Value              = category;
                        cmd.Parameters.Add("@" + COL_DB_VENDORID, SqlDbType.UniqueIdentifier).Value           = vendorID;
                        cmd.Parameters.Add("@" + COL_DB_PRODUCTWIDTHID, SqlDbType.UniqueIdentifier).Value     = Util.wrapNullable(productWidthID);
                        cmd.Parameters.Add("@" + COL_DB_RETAILLENGTHUNITID, SqlDbType.UniqueIdentifier).Value = retailLengthUnitID;
                        cmd.Parameters.Add("@" + COL_DB_BULKLENGTHUNITID, SqlDbType.UniqueIdentifier).Value   = bulkLengthUnitID;
                        cmd.Parameters.Add("@" + COL_DB_BUYRETAILPRICEPERUNIT, SqlDbType.Decimal).Value       = Util.wrapNullable(buyRetailPricePerUnit);
                        cmd.Parameters.Add("@" + COL_DB_BUYBULKPRICEPERUNIT, SqlDbType.Decimal).Value         = Util.wrapNullable(buyBulkPricePerUnit);
                        cmd.Parameters.Add("@" + COL_DB_SELLRETAILPRICEPERUNIT, SqlDbType.Decimal).Value      = Util.wrapNullable(sellRetailPricePerUnit);
                        cmd.Parameters.Add("@" + COL_DB_SELLBULKPRICEPERUNIT, SqlDbType.Decimal).Value        = Util.wrapNullable(sellBulkPricePerUnit);
                        cmd.Parameters.Add("@" + COL_DB_NOTES, SqlDbType.VarChar).Value                       = Util.wrapNullable(notes);

                        cmd.ExecuteNonQuery();

                        ActivityLog.submit(id, "UPDATE: " + log);
                    }
                    Tools.hasMessage("Item updated");
                }
            }
            catch (Exception ex) { Tools.showError(ex.Message); }
        }