예제 #1
0
        public static void update(Guid id, string name)
        {
            try
            {
                Grade objOld = new Grade(id);

                //generate log description
                string logDescription = "";
                if (objOld.Name != name)
                {
                    logDescription = Tools.append(logDescription, String.Format("Name: '{0}' to '{1}'", objOld.Name, name), ",");
                }

                if (!string.IsNullOrEmpty(logDescription))
                {
                    using (SqlCommand cmd = new SqlCommand("grade_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.ExecuteNonQuery();

                        ActivityLog.submitUpdate(id, logDescription);
                    }
                    Tools.hasMessage("Item updated");
                }
            }
            catch (Exception ex) { Tools.showError(ex.Message); }
        }
예제 #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); }
        }
예제 #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); }
        }
예제 #4
0
        /* STATIC METHODS **************************************************************************************/

        public static bool isValidNewBarcode(string barcodeWithPrefix)
        {
            string hex = barcodeWithPrefix.Substring(Settings.itemBarcodeMandatoryPrefix.Length);

            if (!isValidBarcode(barcodeWithPrefix))
            {
                return(false);
            }

            if (isBarcodeExist(hex))
            {
                Tools.hasMessage(String.Format("{0} already exists in database", barcodeWithPrefix));
                return(false);
            }

            return(true);
        }
예제 #5
0
        public static bool isValidBarcode(string barcodeWithPrefix)
        {
            string prefix = barcodeWithPrefix.Substring(0, Settings.itemBarcodeMandatoryPrefix.Length);
            string hex    = barcodeWithPrefix.Substring(Settings.itemBarcodeMandatoryPrefix.Length);

            if (prefix.ToUpper() != Settings.itemBarcodeMandatoryPrefix.ToUpper())
            {
                Tools.hasMessage(String.Format("{0} is not a valid prefix", barcodeWithPrefix.Substring(0, Settings.itemBarcodeMandatoryPrefix.Length)));
                return(false);
            }
            if (hex.Length != Settings.itemBarcodeLength)
            {
                Tools.hasMessage(String.Format("{0} is not a valid barcode: must be {1} digits", barcodeWithPrefix, Settings.itemBarcodeLength));
                return(false);
            }
            if (!Tools.isHexNumber(hex))
            {
                Tools.hasMessage(String.Format("{0} is not a valid barcode", barcodeWithPrefix));
                return(false);
            }

            return(true);
        }