using System; 
using System.Text; 
using System.Data;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Configuration; 
using System.Xml; 
using System.Xml.Serialization;
using SubSonic; 
using SubSonic.Utilities;
namespace DalSic
{
    /// <summary>
    /// Controller class for PN_desc_indicador_ins
    /// </summary>
    [System.ComponentModel.DataObject]
    public partial class PnDescIndicadorInController
    {
        // Preload our schema..
        PnDescIndicadorIn thisSchemaLoad = new PnDescIndicadorIn();
        private string userName = String.Empty;
        protected string UserName
        {
            get
            {
				if (userName.Length == 0) 
				{
    				if (System.Web.HttpContext.Current != null)
    				{
						userName=System.Web.HttpContext.Current.User.Identity.Name;
					}
					else
					{
						userName=System.Threading.Thread.CurrentPrincipal.Identity.Name;
					}
				}
				return userName;
            }
        }
        [DataObjectMethod(DataObjectMethodType.Select, true)]
        public PnDescIndicadorInCollection FetchAll()
        {
            PnDescIndicadorInCollection coll = new PnDescIndicadorInCollection();
            Query qry = new Query(PnDescIndicadorIn.Schema);
            coll.LoadAndCloseReader(qry.ExecuteReader());
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Select, false)]
        public PnDescIndicadorInCollection FetchByID(object IdDescIndicadorIns)
        {
            PnDescIndicadorInCollection coll = new PnDescIndicadorInCollection().Where("id_desc_indicador_ins", IdDescIndicadorIns).Load();
            return coll;
        }
		
		[DataObjectMethod(DataObjectMethodType.Select, false)]
        public PnDescIndicadorInCollection FetchByQuery(Query qry)
        {
            PnDescIndicadorInCollection coll = new PnDescIndicadorInCollection();
            coll.LoadAndCloseReader(qry.ExecuteReader()); 
            return coll;
        }
        [DataObjectMethod(DataObjectMethodType.Delete, true)]
        public bool Delete(object IdDescIndicadorIns)
        {
            return (PnDescIndicadorIn.Delete(IdDescIndicadorIns) == 1);
        }
        [DataObjectMethod(DataObjectMethodType.Delete, false)]
        public bool Destroy(object IdDescIndicadorIns)
        {
            return (PnDescIndicadorIn.Destroy(IdDescIndicadorIns) == 1);
        }
        
        
    	
	    /// <summary>
	    /// Inserts a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Insert, true)]
	    public void Insert(string Descripcion,string DescMedicion,decimal? ValorDeseable)
	    {
		    PnDescIndicadorIn item = new PnDescIndicadorIn();
		    
            item.Descripcion = Descripcion;
            
            item.DescMedicion = DescMedicion;
            
            item.ValorDeseable = ValorDeseable;
            
	    
		    item.Save(UserName);
	    }
    	
	    /// <summary>
	    /// Updates a record, can be used with the Object Data Source
	    /// </summary>
        [DataObjectMethod(DataObjectMethodType.Update, true)]
	    public void Update(int IdDescIndicadorIns,string Descripcion,string DescMedicion,decimal? ValorDeseable)
	    {
		    PnDescIndicadorIn item = new PnDescIndicadorIn();
	        item.MarkOld();
	        item.IsLoaded = true;
		    
			item.IdDescIndicadorIns = IdDescIndicadorIns;
				
			item.Descripcion = Descripcion;
				
			item.DescMedicion = DescMedicion;
				
			item.ValorDeseable = ValorDeseable;
				
	        item.Save(UserName);
	    }
    }
}
