Esempio n. 1
0
        /// <summary>
        /// Update the definintion for a PickItem
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public int PickItemUpdate(PickItem aPickItem)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "UPDATE PICKLISTS SET " +
                            "_NAME = @cName " +
                            "WHERE " +
                            "_PICKLISTID = @nPicklistID";

                        SqlCeParameter[] spParams = new SqlCeParameter[2];
                        spParams[0] = new SqlCeParameter("@nPicklistID", aPickItem.PickItemID);
                        spParams[1] = new SqlCeParameter("@cName", aPickItem.Name);

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            command.Parameters.AddRange(spParams);
                            command.ExecuteNonQuery();
                        }
                    }
                }
                catch (SqlCeException ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");
                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
                catch (Exception ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");

                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
            }
            else
            {
                AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess();
                lAuditWizardDataAccess.PickItemUpdate(aPickItem);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(0);
        }
Esempio n. 2
0
        /// <summary>
        /// Add a new PickItem (to an existing PickList)
        /// </summary>
        /// <param name="row"></param>
        public void AddPickItem(DataRow row)
        {
            // Can we find a definition for the associated PickList?
            // If not then we fail as we cannot add a PickItem to a non-existant PickList
            PickList pickList = FindPickList((int)row["_PARENTID"]);

            if (pickList != null)
            {
                //throw new Exception("Invalid PickItem with index [" + ((int)row["_PARENTID"]).ToString() + "] Associated with PickItem [" + ((int)row["_NAME"]).ToString() + "]");
                PickItem pickItem = new PickItem(row);
                pickList.Add(pickItem);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Equality test - check to see if this instance matches another
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj != null && obj.GetType().Equals(this.GetType()))
            {
                PickItem other = obj as PickItem;

                if ((object)other != null)
                {
                    bool equality;
                    equality = other.PickItemID == PickItemID &&
                               other.Name == Name &&
                               other.ParentID == ParentID;
                    return(equality);
                }
            }
            return(base.Equals(obj));
        }
Esempio n. 4
0
 /// <summary>
 /// Copy constructor
 /// </summary>
 /// <param name="other"></param>
 public PickItem(PickItem other)
 {
     _pickitemID = other._pickitemID;
     _name       = other._name;
     _parentID   = other._parentID;
 }
Esempio n. 5
0
        /// <summary>
        /// Add a new PickItem to the database
        /// </summary>
        /// <param name="theAlert"></param>
        /// <returns></returns>
        public int PickItemAdd(PickItem aPickItem)
        {
            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " in");
            }

            int lItemID = 0;

            if (compactDatabaseType)
            {
                try
                {
                    using (SqlCeConnection conn = DatabaseConnection.CreateOpenCEConnection())
                    {
                        string commandText =
                            "INSERT INTO PICKLISTS " +
                            "(_NAME ,_PARENTID) " +
                            "VALUES " +
                            "(@cName, @nParentID)";

                        SqlCeParameter[] spParams = new SqlCeParameter[2];
                        spParams[0] = new SqlCeParameter("@cName", aPickItem.Name);
                        spParams[1] = new SqlCeParameter("@nParentID", aPickItem.ParentID);

                        using (SqlCeCommand command = new SqlCeCommand(commandText, conn))
                        {
                            command.Parameters.AddRange(spParams);
                            command.ExecuteNonQuery();
                        }

                        using (SqlCeCommand command = new SqlCeCommand("SELECT @@IDENTITY", conn))
                        {
                            lItemID = Convert.ToInt32(command.ExecuteScalar());
                        }
                    }
                }
                catch (SqlCeException ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");
                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
                catch (Exception ex)
                {
                    Utility.DisplayErrorMessage("A database error has occurred in AuditWizard." + Environment.NewLine + Environment.NewLine +
                                                "Please see the log file for further details.");

                    logger.Error("Exception in " + System.Reflection.MethodBase.GetCurrentMethod().Name, ex);
                }
            }
            else
            {
                AuditWizardDataAccess lAuditWizardDataAccess = new AuditWizardDataAccess();
                lItemID = lAuditWizardDataAccess.PickItemAdd(aPickItem);
            }

            if (isDebugEnabled)
            {
                logger.Debug(System.Reflection.MethodBase.GetCurrentMethod().Name + " out");
            }
            return(lItemID);
        }