/// <summary> /// Exists: /// </summary> /// <param name="pCObject"></param> /// <returns></returns> public bool Exists(CObject pCObject, ParameterToSearch parameter) { if (this.Read(pCObject, parameter) != null) return true; else return false; }
/// <summary> /// Create: /// </summary> /// <param name="pCObject"></param> public string Create(CObject pCObject, ParameterToSearch parameter) { string salida = ""; if (!this.Exists(pCObject, ParameterToSearch.Descripcion)) { try { bool result = true; List<CObject> list = new List<CObject>(); list = this.DALAsociados.ReadAll(); if (list.Count > 0) { (DALConnection as DALEvento).Create(pCObject); CObject evento = (this.DALConnection as DALEvento).ReadByDescription(pCObject); (this.DALConnection as DALEvento).CopyDataFromAsociadosToBitacora(evento); } else { salida = "Debe realizar la carga de Asociados antes de crear un evento"; } } catch (Exception error) { salida = error.Message; } } else { salida = "Ya existe un evento con este nombre!!!"; } return salida; }
/// <summary> /// Create: /// </summary> /// <param name="pObject"></param> public void Create(CObject pObject) { // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command command.CommandType = CommandType.StoredProcedure; //command.CommandType = CommandType.Text; // SQL Instruction string sql = @"sp_CierreMesa_Create"; // Set Parameters: @ for inner parameters into SQL statement command.Parameters.AddWithValue("@IdEvento", ((pObject) as CCierreMesa).IdEvento); command.Parameters.AddWithValue("@IdUsuario", ((pObject) as CCierreMesa).IdUsuario); command.Parameters.AddWithValue("@UsuarioActualizacion", ((pObject) as CCierreMesa).UsuarioModificacion); // Set sql instruction command.CommandText = sql; // Execute db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } }
/// <summary> /// Create: /// </summary> /// <param name="pObject"></param> public void Create(CObject pObject) { // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command command.CommandType = CommandType.StoredProcedure; //command.CommandType = CommandType.Text; // SQL Instruction string sql = @"sp_Eventos_CREATE"; // Set Parameters: @ for inner parameters into SQL statement command.Parameters.AddWithValue("@Descripcion", ((pObject) as CEvento).Descripcion); command.Parameters.AddWithValue("@FechaEvento", ((pObject) as CEvento).FechaEvento); command.Parameters.AddWithValue("@Estado", ((pObject) as CEvento).Estado); command.Parameters.AddWithValue("@UsuarioCreacion", ((pObject) as CEvento).UsuarioCreacion); // Set sql instruction command.CommandText = sql; // Execute db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } }
/// <summary> /// Read: /// </summary> /// <param name="pCObject"></param> /// <returns></returns> public CObject Read(CObject pCObject, ParameterToSearch parameter) { CObject CObject = new CObject(); if (parameter == ParameterToSearch.Id) { CObject = (this.DALConnection as DALCierreMesa).ReadById(pCObject); } return CObject; }
/// <summary> /// Delete: /// </summary> /// <param name="pCObject"></param> public void Delete(CObject pCObject, ParameterToSearch parameter) { if (this.Exists((pCObject as CEvento), parameter)) { (DALConnection as DALEvento).Delete(pCObject); } else { throw new Exception("Registro no existe!!!"); } }
/// <summary> /// Delete: /// </summary> /// <param name="pCObject"></param> public void Delete(CObject pCObject) { if (this.Exists((pCObject as CEvento).Usuario)) { (DALConnection as DALEvento).Delete(pCObject); } else { throw new Exception("Registro no existe!!!"); } }
/// <summary> /// Create: /// </summary> /// <param name="pCObject"></param> public void Create(CObject pCObject, ParameterToSearch parameter) { if (!this.Exists(pCObject, ParameterToSearch.Descripcion)) { (DALConnection as DALCierreMesa).Create(pCObject); } else { throw new Exception("Ya existe este registro!!!"); } }
/// <summary> /// Create: /// </summary> /// <param name="pCObject"></param> public void Create(CObject pCObject) { if (!this.Exists(pCObject)) { (DALConnection as DALEvento).Create(pCObject); } else { throw new Exception("Ya existe este registro!!!"); } }
/// <summary> /// ReadAll: /// </summary> /// <returns></returns> public string Update(CObject cObject) { string result = ""; try { (DALConnection as DALBitacora).Update(cObject); result = "Registro Actualizado correctamente"; } catch (Exception) { result = "No se pudo actualizar el registro"; } return result; }
public WCFUsuario ReadUser(CObject entity) { CObject Entity = (DALConnection as DALUsuario).Read(entity); WCFUsuario WCFUsuario = new WCFUsuario() { Id = (Entity as CUsuario).Id, Nombre = (Entity as CUsuario).Nombre, Usuario = (Entity as CUsuario).Usuario, Contrasena = (Entity as CUsuario).Contrasena, Role = (Entity as CUsuario).Role, Estado = (Entity as CUsuario).Estado, UsuarioCreacion = (Entity as CUsuario).UsuarioCreacion, FechaCreacion = (Entity as CUsuario).FechaCreacion, UsuarioModificacion = (Entity as CUsuario).UsuarioModificacion, FechaModificacion = (Entity as CUsuario).FechaModificacion }; return WCFUsuario; }
public void Delete(CObject pObject) { // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command command.CommandType = CommandType.StoredProcedure; //command.CommandType = CommandType.Text; // SQL Instruction string sql = @"sp_Asociados_DELETE_ALL"; // Set Parameters: @ for inner parameters into SQL statement //command.Parameters.AddWithValue("@IdEvento", ((pObject) as CEvento).Id); // Set sql instruction command.CommandText = sql; // Execute db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } }
public CObject ReadById(CObject pObject) { // Object CObject oCObject = null; // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { DataSet ds = null; SqlCommand command = new SqlCommand(); command.CommandType = CommandType.StoredProcedure; string sql = @"sp_Eventos_READ_ById"; // Set Parameters command.Parameters.AddWithValue("@IdEvento", ((pObject) as CEvento).Id); //command.Parameters.AddWithValue("@CONTRASENA", ((pObject) as CUsuario).Contrasena); // Set sql instruction command.CommandText = sql; // Execute ds = db.ExecuteReader(command, "Eventos"); // Extract table 0 DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; oCObject = this.PopulateObject(dr); } else { oCObject = null; } return oCObject; } }
/// <summary> /// Exists: /// </summary> /// <param name="pObject"></param> /// <returns></returns> public bool Exists(CObject pObject) { // Object CObject oCObject = this.ReadById(pObject); // If not is null then true if (oCObject != null) { return true; } else { return false; } }
/// <summary> /// Update: /// </summary> /// <param name="pCObject"></param> public void Update(CObject pCObject) { if (this.ValidateUser((pCObject as CUsuario).Usuario)) { (this.DALConnection as DALUsuario).Update(pCObject); } else { throw new Exception("Registro no existe!!!"); } }
//public MembershipUser ReadUser(CObject entity)/ public bool ReadUser(CObject entity) { throw new NotImplementedException(); }
/// <summary> /// Read: /// </summary> /// <param name="pCObject"></param> /// <returns></returns> public CObject Read(CObject pCObject) { return (this.DALConnection as DALUsuario).Read(pCObject); }
/// <summary> /// Read: /// </summary> /// <param name="pCObject"></param> /// <returns></returns> public CObject Read(CObject pCObject, ParameterToSearch parameter) { CObject CObject = new CObject(); if (parameter == ParameterToSearch.Id) { CObject = (this.DALConnection as DALEvento).ReadById(pCObject); } if (parameter == ParameterToSearch.Descripcion) { CObject = (this.DALConnection as DALEvento).ReadByDescription(pCObject); } return CObject; }
/// <summary> /// Read: /// </summary> /// <param name="pCObject"></param> /// <returns></returns> public CObject Read(CObject pCObject) { return (this.DALConnection as DALEvento).ReadById(pCObject); }
/// <summary> /// Exists: /// </summary> /// <param name="pCObject"></param> /// <returns></returns> public bool Exists(CObject pCObject) { return (DALConnection as DALEvento).(pCObject); }
/// <summary> /// Update: /// </summary> /// <param name="pCObject"></param> private void CopyDataFromAsociadosToBitacora(CObject pCObject, ParameterToSearch parameter) { (this.DALConnection as DALEvento).CopyDataFromAsociadosToBitacora(pCObject); }
/// <summary> /// Update: /// </summary> /// <param name="pObject"></param> public void Update(CObject pObject) { // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command command.CommandType = CommandType.StoredProcedure; //command.CommandType = CommandType.Text; // SQL Instruction string sql = @"sp_usuarios_UPDATEById"; // Set Parameters: @ for inner parameters into SQL statement command.Parameters.AddWithValue("@IdUsuario", ((pObject) as CUsuario).Id); command.Parameters.AddWithValue("@Nombre", ((pObject) as CUsuario).Nombre); command.Parameters.AddWithValue("@Usuario", ((pObject) as CUsuario).Usuario); command.Parameters.AddWithValue("@Contrasena", ((pObject) as CUsuario).Contrasena); command.Parameters.AddWithValue("@Rol", ((pObject) as CUsuario).Role.ToString()); command.Parameters.AddWithValue("@Estado", ((pObject) as CUsuario).Estado.ToString()); command.Parameters.AddWithValue("@UsuarioModificacion", ((pObject) as CUsuario).UsuarioModificacion); // Set sql instruction command.CommandText = sql; // Execute db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } }
//public MembershipUser ReadUser(CObject entity)/ public bool ReadUser(CObject entity) { WCFUsuario WCFuser = this.servicio.ReadUser(entity); if (WCFuser!=null) { return true; } else { return false; } }
/* #region CRUD #region CRUD:Create /// <summary> /// Create: /// </summary> /// <param name="pObject"></param> public void Create(Entity pObject) { // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command //command.CommandType = CommandType.StoredProcedure; command.CommandType = CommandType.Text; // SQL Instruction string sql = @"INSERT INTO DIVISION (idDivision, division, descripcion) VALUES (@idDivision, @division, @despcripcion)"; // Set Parameters: @ for inner parameters into SQL statement command.Parameters.AddWithValue("@idDivision", ((pObject) as CUsuario).IdDivision); command.Parameters.AddWithValue("@division", ((pObject) as CUsuario).Division); command.Parameters.AddWithValue("@descripcion", ((pObject) as CUsuario).Descripcion); // Set sql instruction command.CommandText = sql; // Execute db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } } #endregion /// <summary> /// Read All: /// </summary> /// <returns></returns> public List<Entity> ReadAll() { // List List<Entity> objCollection = new List<Entity>(); // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // DataSet: Disconnected data. DataSet ds = null; // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command //command.CommandType = CommandType.StoredProcedure; command.CommandType = CommandType.Text; // SQL Instruction string sql = @"SELECT * FROM DIVISION"; // Set Parameters // Set sql instruction command.CommandText = sql; // Execute ds = db.ExecuteReader(command, "query"); // Extract table 0 DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { foreach (DataRow dr in dt.Rows) { Entity oCObject = new CUsuario(); oCObject = this.PopulateObject(dr); objCollection.Add(oCObject); } } return objCollection; } } #endregion #region CRUD:Update /// <summary> /// Update: /// </summary> /// <param name="pObject"></param> public void Update(Entity pObject) { // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command //command.CommandType = CommandType.StoredProcedure; command.CommandType = CommandType.Text; // SQL Instruction string sql = @"UPDATE DIVISION SET idDivision = @idDivision, division= @division, descripcion = @descripcion WHERE idDivsion = @idDivision;"; // Set Parameters: @ for inner parameters into SQL statement command.Parameters.AddWithValue("@idDivision", ((pObject) as CUsuario).IdDivision); // Set sql instruction command.CommandText = sql; // Execute db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } } #endregion #region CRUD:Delete /// <summary> /// Delete /// </summary> /// <param name="pObject"></param> public void Delete(Entity pObject) { // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command //command.CommandType = CommandType.StoredProcedure; command.CommandType = CommandType.Text; // SQL Instruction string sql = @"DELETE FROM DIVISION WHERE idDivsion = @idDivision;"; // Set Parameters: @ for inner parameters into SQL statement command.Parameters.AddWithValue("@idDivision", ((pObject) as CUsuario).IdDivision); // Set sql instruction command.CommandText = sql; // Execute db.ExecuteNonQuery(command, IsolationLevel.ReadCommitted); } } #endregion #region CRUD:Exists /// <summary> /// Exists: /// </summary> /// <param name="pObject"></param> /// <returns></returns> public bool Exists(Entity pObject) { // Object Entity oCObject = this.Read(pObject); // If not is null then true if (oCObject!=null) { return true; } else { return false; } } #endregion */ #region CRUD:Read /// <summary> /// Read By Id: /// </summary> /// <param name="pId"></param> /// <returns></returns> public CObject Read(CObject pObject) { // Object CObject oCObject = null; // Execute Instruction using (DataBase db = DataBaseFactory.OpenDatabase(base.ConnectionStringName)) { // DataSet: Disconnected data. DataSet ds = null; // Create Command //OleDbCommand command = new OleDbCommand(); SqlCommand command = new SqlCommand(); //MySqlCommand command = new MySqlCommand(); // Define Type of command //command.CommandType = CommandType.StoredProcedure; command.CommandType = CommandType.Text; // SQL Instruction string sql = @"SELECT * FROM USUARIOS WHERE USUARIO = @USUARIO AND CONTRASENA = @CONTRASENA"; // Set Parameters command.Parameters.AddWithValue("@USUARIO", ((pObject) as CUsuario).Usuario); command.Parameters.AddWithValue("@CONTRASENA", ((pObject) as CUsuario).Contrasena); // Set sql instruction command.CommandText = sql; // Execute ds = db.ExecuteReader(command, "USUARIO"); // Extract table 0 DataTable dt = ds.Tables[0]; if (dt.Rows.Count > 0) { DataRow dr = dt.Rows[0]; oCObject = this.PopulateObject(dr); } else { oCObject = null; } return oCObject; } }
/// <summary> /// Exists: /// </summary> /// <param name="pCObject"></param> /// <returns></returns> public bool Exists(CObject pCObject) { return (DALConnection as DALUsuario).Exists(pCObject); }