/// <summary>
        /// Procedure to update the expiry date of a product
        /// </summary>
        /// <param name="reference">the product's reference</param>
        /// <param name="expiryData">the expiry date</param>
        public void UpdateExipryDate(string reference, DateTime expiryData)
        {
            SqlCeConnection conn = null;

            try
            {
                string sqlconnection = ("Data Source ="
                                        + (System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) + "\\InventoryDB.sdf;"));

                using (conn = new SqlCeConnection(sqlconnection))
                {
                    conn.Open();

                    SqlCeCommand cmd = conn.CreateCommand();

                    cmd.CommandText = "select * from Products where Reference ='" + reference + "'";

                    SqlCeResultSet rs = cmd.ExecuteResultSet(ResultSetOptions.Updatable |
                                                             ResultSetOptions.Scrollable);

                    SqlCeUpdatableRecord rec = rs.CreateRecord();
                    if (true == rs.ReadAbsolute(0))
                    {
                        rs.SetDateTime(3, expiryData);
                        rs.Update();
                    }
                }
            }
            finally
            {
                conn.Close();
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Reads records from absolute position
 /// </summary>
 public override void ReadAbsolute(int position, int count, Action <IDataRecord> process)
 {
     for (int i = 0; i < count; ++i)
     {
         if (_resultSet.ReadAbsolute(position + i))
         {
             process(_resultSet);
         }
     }
 }