示例#1
0
        public bool UpdateUser(string name, string password, string confirm, Locations defaultLocation, string LPNPrinter)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ApplicationException("You must provide a User Name.");
            }

            if (string.IsNullOrEmpty(password))
            {
                throw new ApplicationException("You must provide a User Password.");
            }

            if (string.IsNullOrEmpty(confirm))
            {
                throw new ApplicationException("Please confirm the password.");
            }

            if (string.Compare(password, confirm, false) != 0)
            {
                throw new ApplicationException("The passwords do not match.");
            }

            Users user = Session.DefaultSession.GetObjectByKey <Users>(name);

            if (user == null)
            {
                //It is a new user
                return(InsertUser(name, password, defaultLocation, LPNPrinter));
            }

            //Dim originalRecord As Object() = user.ItemArray

            Change change = new Change()
            {
                PropertyName = Users.Fields.strUserName.PropertyName,
                PrevValue    = user.strUserName,
                NewValue     = user.strUserName
            };

            changes.Add(change);

            SetField(Users.Fields.strPassword.PropertyName, user.strPassword, password, user);
            SetField(Users.Fields.DefaultLocation.PropertyName, user.DefaultLocation, defaultLocation, user);
            SetField(Users.Fields.LPNPrinterName.PropertyName, user.LPNPrinterName, LPNPrinter, user);

            //user.strPassword = password

            //If Not IsNothing(originalRecord) Then
            //    UpdateAuditTrail(user, originalRecord)
            //End If

            //Return Adapter.Update(user) = 1


            try
            {
                user.Save();
            }
            catch (Exception ex)
            {
                return(false);
            }

            UpdateAuditTrail();

            return(true);
        }
示例#2
0
        public bool UpdateProduct(int itemID, string itemCode, string itemDescription, string itemType, int?itemCustomerID, int?itemDefaultMachine, double?itemProdStandard, double?dblPrice, float?sngRebate, string strUnitOfMeasure, double?intQtyPerUnit, double?dblFreight, double?dblFilm, double?dblBoxes, double?dblStretchWrap, double?dblPallets, double?dblOther1, double?dblOther2, double?dblOther3, double?dblOther4, double?dblOther5, double?intUnitsPerCase, int?intUnitsPerPallet, int?intCasesPerPallet, float?sngQtyOnHand, double?CaseGrossWeight, string PackageCode, string CaseCode, string RequiredWeight, string MAV, string CasesPerLayer, string LayersPerPallet, string ShelfLife, string Instructions, string PalletPattern, bool inactive, double?packers, string upc, int?bagsPerCase, bool?RequiresLotCode, bool?RequiresExpirationDate, bool?GenerateLotCodes, int?DefaultLotCodeFormat, double?MinutesPerSift, string AllergenInfo, Session dxSession)
        {
            StringBuilder str = new StringBuilder(string.Empty);

            if (string.IsNullOrEmpty(itemCode))
            {
                str.Append("Item Code, ");
            }
            if (string.IsNullOrEmpty(itemType))
            {
                str.Append("Item Type, ");
            }
            if (!itemCustomerID.HasValue)
            {
                str.Append("Customer name, ");
            }
            if (!DefaultLotCodeFormat.HasValue && RequiresLotCode.HasValue == true && RequiresLotCode == true && itemCustomerID.HasValue && dxSession.GetObjectByKey <Customers>(itemCustomerID.Value).DefaultLotCodeFormat == null)
            {
                str.Append("Default Lot Code Format, ");
            }

            if (str.Length > 0)
            {
                throw new ApplicationException(string.Format("You must provide a {0}.", str.ToString().Substring(0, (str.Length - 2))));
            }

            if (!string.IsNullOrEmpty(upc))
            {
                CriteriaOperatorCollection theCriteria = new CriteriaOperatorCollection();
                theCriteria.Add(new BinaryOperator(Items.Fields.UPC.PropertyName, upc, BinaryOperatorType.Equal));
                theCriteria.Add(new BinaryOperator(Items.Fields.ItemID.PropertyName, itemID, BinaryOperatorType.NotEqual));

                if (dxSession.GetObjects(dxSession.GetClassInfo <Items>(), new GroupOperator(GroupOperatorType.And, theCriteria), null, 1, false, true).Count > 0)
                {
                    throw new ApplicationException("UPC must be unique.");
                }
            }

            //Dim products As SPG.ItemsDataTable = Adapter.GetItemByID(itemID)

            //If products.Count = 0 Then
            Change change  = new Change();
            Items  product = dxSession.GetObjectByKey <Items>(itemID);

            if (product == null)
            {
                //It is a new Customer
                change = new Change()
                {
                    PropertyName = Items.Fields.ItemID.PropertyName,
                    PrevValue    = "<NULL>",
                    NewValue     = itemID.ToString()
                };
                changes.Add(change);
                //It is a new Product
                return(InsertProduct(itemID, itemCode, itemDescription, itemType, itemCustomerID, itemDefaultMachine, itemProdStandard, dblPrice, sngRebate, strUnitOfMeasure, intQtyPerUnit, dblFreight, dblFilm, dblBoxes, dblStretchWrap, dblPallets, dblOther1, dblOther2, dblOther3, dblOther4, dblOther5, intUnitsPerCase, intUnitsPerPallet, intCasesPerPallet, sngQtyOnHand, CaseGrossWeight, PackageCode, CaseCode, RequiredWeight, MAV, CasesPerLayer, LayersPerPallet, ShelfLife, Instructions, PalletPattern, inactive, packers, upc, bagsPerCase, RequiresLotCode, RequiresExpirationDate, GenerateLotCodes, DefaultLotCodeFormat, MinutesPerSift, AllergenInfo, dxSession));
            }

            //Dim product As SPG.ItemsRow = products(0)

            //Dim originalRecord As Object() = Nothing
            //originalRecord = product.ItemArray

            change = new Change()
            {
                PropertyName = Items.Fields.ItemID.PropertyName,
                PrevValue    = product.ItemID.ToString(),
                NewValue     = product.ItemID.ToString()
            };
            changes.Add(change);

            SetProductFields(itemCode, itemDescription, itemType, itemCustomerID, itemDefaultMachine, itemProdStandard, dblPrice, sngRebate, strUnitOfMeasure, intQtyPerUnit, dblFreight, dblFilm, dblBoxes, dblStretchWrap, dblPallets, dblOther1, dblOther2, dblOther3, dblOther4, dblOther5, intUnitsPerCase, intUnitsPerPallet, intCasesPerPallet, sngQtyOnHand, CaseGrossWeight, PackageCode, CaseCode, RequiredWeight, MAV, CasesPerLayer, LayersPerPallet, ShelfLife, Instructions, PalletPattern, inactive, packers, upc, bagsPerCase, RequiresLotCode, RequiresExpirationDate, GenerateLotCodes, DefaultLotCodeFormat, MinutesPerSift, AllergenInfo, product, dxSession);

            try
            {
                product.Editing = false;
                product.Save();
            }
            catch (Exception ex)
            {
                return(false);
            }

            //If Not IsNothing(originalRecord) Then
            //    ItemsBLL.UpdateAuditTrail(product, originalRecord)
            //End If

            //Dim rowsAffected As Integer = Adapter.Update(product)

            UpdateAuditTrail();

            //Return rowsAffected = 1

            return(true);
        }
示例#3
0
        public bool UpdateShipping(int shippingID, DateTime?shippingDate, int?shippingCarrierID, int?shippingCustID, int?shippingBol, int?intDestination, string strPO, string strTrailer, float?sngSkits, float?sngTotalPallets, string strSeal, string strDeliveryNote, string DeliveryNoteNumber, double?TotalGrossWeight, bool?Shipper, string Comments, int?Shift, bool Freight, int?loadedBy, int?checkedBy, int?wheelsChocked, DateTime?startTime, DateTime?finishTime, double?temparature, int?physicalCondition, int?loadCondition, int?foreignSubstance, int?insectActivity, int?correctPallets, int locationID)
        {
            StringBuilder str = new StringBuilder(string.Empty);

            if (!shippingCustID.HasValue)
            {
                str.Append("Customer Name, ");
            }

            if (!shippingCarrierID.HasValue)
            {
                str.Append("Carrier Name, ");
            }

            if (!intDestination.HasValue)
            {
                str.Append("Destination, ");
            }

            if (str.Length > 0)
            {
                throw new ApplicationException(string.Format("You must provide a {0}.", str.ToString().Substring(0, str.Length - 2)));
            }

            Change   change         = new Change();
            Shipping shippingRecord = Session.DefaultSession.GetObjectByKey <Shipping>(shippingID);

            if (shippingRecord == null)
            {
                //It is a new shipping
                //It must have all the quantity fields filled in
                if (temparature.HasValue == false || physicalCondition.HasValue == false || loadCondition.HasValue == false || foreignSubstance.HasValue == false || insectActivity.HasValue == false || correctPallets.HasValue == false || wheelsChocked.HasValue == false || loadedBy.HasValue == false || checkedBy.HasValue == false || string.IsNullOrEmpty(strTrailer))
                {
                    throw new ApplicationException("You must fill in all the quality fields.");
                }
                change = new Change()
                {
                    PropertyName = Shipping.Fields.ShipMainID.PropertyName,
                    PrevValue    = "<NULL>",
                    NewValue     = shippingID.ToString()
                };
                changes.Add(change);
                return(InsertShipping(shippingID, shippingDate, shippingCarrierID, shippingCustID, shippingBol, intDestination, strPO, strTrailer, sngSkits, sngTotalPallets, strSeal, strDeliveryNote, DeliveryNoteNumber, TotalGrossWeight, Shipper, Comments, Shift, Freight, loadedBy, checkedBy, wheelsChocked, startTime, finishTime, temparature, physicalCondition, loadCondition, foreignSubstance, insectActivity, correctPallets, locationID));
            }

            change = new Change()
            {
                PropertyName = Shipping.Fields.ShipMainID.PropertyName,
                PrevValue    = shippingRecord.ShipMainID.ToString(),
                NewValue     = shippingRecord.ShipMainID.ToString()
            };
            changes.Add(change);
            SetShippingFields(shippingDate, shippingCarrierID, shippingCustID, shippingBol.Value, intDestination, strPO, strTrailer, sngSkits, sngTotalPallets, strSeal, strDeliveryNote, DeliveryNoteNumber, TotalGrossWeight, Shipper, Comments, Shift, Freight, loadedBy, checkedBy, wheelsChocked, startTime, finishTime, temparature, physicalCondition, loadCondition, foreignSubstance, insectActivity, correctPallets, locationID, shippingRecord);

            try
            {
                shippingRecord.Save();
            }
            catch (Exception ex)
            {
                return(false);
            }

            UpdateAuditTrail();

            return(true);
        }