public static Response ExecuteNonQuery(string query, Connection connection, bool call = true) { using (var ifxConnection = new IfxConnection(connection.ConnectionString)) { try { ifxConnection.Open(); var ifxCommand = new IfxCommand(query) { Connection = ifxConnection, CommandTimeout = 0 }; return(new Response(ifxCommand.ExecuteNonQuery())); } catch (Exception exception) { if (!call) { return(new Response(Status.Exception, exception.Message)); } ExecuteNonQuery(query, connection, false); return(new Response(Status.Exception, exception.Message)); } finally { ifxConnection.Close(); } } }
public IActionResult Index() { DataTable table = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); try { IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM Mobiles", Con); ifx.Fill(table); } catch (Exception ex) { string createTable = "Create table Mobiles (SLNo serial PRIMARY KEY, MobileName nvarchar(100) NULL, Price decimal(18, 2)," + " Quantity int NULL, Description nvarchar(250) NULL, PicURL nvarchar(250) NULL," + " Model nvarchar(50) NULL, Features nvarchar(200) NULL, Color nvarchar(20) NULL, SimType nvarchar(10) NULL, ImageFile Blob)"; IfxCommand cmd = new IfxCommand(createTable, Con); cmd.ExecuteNonQuery(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM Mobiles", Con); ifx.Fill(table); } finally { Con.Close(); } } return(View(table)); }
public IActionResult Index() { DataTable table = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); try { IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM orderdetails", Con); ifx.Fill(table); } catch (Exception ex) { string createTable = "Create table orderdetails (orderid serial PRIMARY KEY, SLNo int, MobileName nvarchar(100) NULL, " + " Description nvarchar(250) NULL, PicURL nvarchar(250) NULL, Model nvarchar(50) NULL, Features nvarchar(200) NULL, " + "Color nvarchar(20) NULL, SimType nvarchar(10) NULL, PurchaseDate varchar(50), Price decimal(18, 2), Quantity int NULL, TotalAmount decimal(18,2))"; IfxCommand cmd = new IfxCommand(createTable, Con); cmd.ExecuteNonQuery(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM orderdetails", Con); ifx.Fill(table); } finally { Con.Close(); } return(View(table)); } }
public ActionResult Index() { DataTable table = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); try { IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM Product", Con); ifx.Fill(table); } catch (Exception ex) { string createProductTable = "Create table Product (productid serial PRIMARY KEY, productname varchar(50), price decimal(18,2), count int)"; IfxCommand cmd = new IfxCommand(createProductTable, Con); cmd.ExecuteNonQuery(); string createOrderTable = "Create table orderdetails (orderid serial PRIMARY KEY, productid int, productname varchar(50), price decimal(18,2), count int, totalamount decimal(18,2))"; IfxCommand cmd1 = new IfxCommand(createOrderTable, Con); cmd1.ExecuteNonQuery(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM Product", Con); ifx.Fill(table); } } return(View(table)); }
public bool Eliminar(int id) { bool respuesta = false; try { AbrirConexion(); var sql = "execute procedure dml_roles_vista (?,NULL,?,NULL);"; using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "DELETE"; cmd.Parameters.Add(new IfxParameter()).Value = id; cmd.ExecuteNonQuery(); } respuesta = true; } catch (Exception exc) { throw exc; } finally { CerrarConexion(); } return(respuesta); }
public bool Insert(EntEmpleado entidad) { bool respuesta = false; try { var sql = string.Empty; AbrirConexion(); if (entidad.imagen != null) { sql = "execute procedure dml_empleados (?,NULL,?,?,?,?,?,?,?,?);"; } else { sql = "execute procedure dml_empleados (?,NULL,?,?,?,?,?,?,NULL,?);"; } using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "INSERT"; cmd.Parameters.Add(new IfxParameter()).Value = entidad.nombre; cmd.Parameters.Add(new IfxParameter()).Value = entidad.ap_paterno; cmd.Parameters.Add(new IfxParameter()).Value = entidad.ap_materno; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_departamento; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_sucursal; cmd.Parameters.Add(new IfxParameter()).Value = entidad.enrollnumber; if (entidad.imagen != null) { cmd.Parameters.Add(new IfxParameter()).Value = entidad.imagen; } cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_dispositivo; cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insert Empleados"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insert Empleados"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
public bool Update(EntDispositivo entidad) { bool respuesta = false; try { var sql = string.Empty; AbrirConexion(); if (entidad.imagen != null) { sql = "execute procedure dml_dispositivo (?,?,?,?,?,?,?,?,?,?);"; } else { sql = "execute procedure dml_dispositivo (?,?,?,?,?,?,?,NULL,?,?);"; } using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "UPDATE"; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_dispositivo; cmd.Parameters.Add(new IfxParameter()).Value = entidad.nombre_dispositivo; cmd.Parameters.Add(new IfxParameter()).Value = entidad.numero_serie; cmd.Parameters.Add(new IfxParameter()).Value = entidad.ip_dispositivo; cmd.Parameters.Add(new IfxParameter()).Value = entidad.puerto; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_sucursal; if (entidad.imagen != null) { cmd.Parameters.Add(new IfxParameter()).Value = entidad.imagen; } cmd.Parameters.Add(new IfxParameter()).Value = entidad.rh; cmd.Parameters.Add(new IfxParameter()).Value = entidad.numeroequipo; cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Dispositivo"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Dispositivo"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
public static int RunSP(string spName, IfxConnection conn) { IfxCommand cmd = new IfxCommand(spName, conn); cmd.CommandType = CommandType.StoredProcedure; if (conn.State == System.Data.ConnectionState.Closed) { conn.Open(); } return(cmd.ExecuteNonQuery()); }
public bool Update(EntEmpresa entidad) { bool respuesta = false; try { var sql = string.Empty; AbrirConexion(); if (entidad.imagen != null) { sql = "execute procedure dml_empresa (?,?,?,?,?,?,?);"; } else { sql = "execute procedure dml_empresa (?,?,?,?,?,?,NULL);"; } using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "UPDATE"; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_empresa; cmd.Parameters.Add(new IfxParameter()).Value = entidad.razon_social; cmd.Parameters.Add(new IfxParameter()).Value = entidad.direccion; cmd.Parameters.Add(new IfxParameter()).Value = entidad.estado; cmd.Parameters.Add(new IfxParameter()).Value = entidad.municipio; if (entidad.imagen != null) { cmd.Parameters.Add(new IfxParameter()).Value = entidad.imagen; } cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Empresa"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Empresa"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
private void updateToCart(IfxConnection con, Mobiles mobile, int selectedQuantity, int savedQuantity, decimal itemPrice) { int totalQuantity = selectedQuantity + savedQuantity; decimal totalamount = itemPrice * totalQuantity; string updateQuery = "UPDATE Cart SET (Quantity, TotalAmount) = (?, ?) Where SLNo = ?"; IfxCommand cmd = new IfxCommand(updateQuery, con); cmd.Parameters.Add("quantity", IfxType.Int).Value = totalQuantity; cmd.Parameters.Add("totalamount", IfxType.Decimal).Value = totalamount; cmd.Parameters.Add("slno", IfxType.Int).Value = mobile.SLNo; cmd.ExecuteNonQuery(); }
public ActionResult Delete(int id) { using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); string query = "DELETE FROM Product WHere productid = ?"; IfxCommand cmd = new IfxCommand(query, Con); cmd.Parameters.Add("productid", IfxType.Serial).Value = id; cmd.ExecuteNonQuery(); } return(RedirectToAction("Index")); }
public void Insertar_Enrrolamiento_BD(List <checkinout> ListaEmpleadoEnrrolamiento) { var connectionString = ConfigurationManager.ConnectionStrings["DBInformix"].ConnectionString; PerInformixDB per = new PerInformixDB(); try { per.AbrirConexion(); EventLog.WriteEntry("Insercion de Datos a la Base de Datos"); foreach (checkinout entidad in ListaEmpleadoEnrrolamiento) { var sql = "insert into checkinout (enrollnumber,date,hour,checkinout,device,id_dispositivo,id_empleado) values (?,?,?,?,?,?,?);"; using (var cmd = new IfxCommand(sql, per.Conexion)) { cmd.Parameters.Add(new IfxParameter()).Value = entidad.numeroCredencial; cmd.Parameters.Add(new IfxParameter()).Value = entidad.pFecha; cmd.Parameters.Add(new IfxParameter()).Value = entidad.pHora; cmd.Parameters.Add(new IfxParameter()).Value = entidad.Ckecked; cmd.Parameters.Add(new IfxParameter()).Value = entidad.Device; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_dispositivo; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_empleado; cmd.ExecuteNonQuery(); } string filePath = ConfigurationManager.AppSettings["file_log"]; using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine(Environment.NewLine + "---Inserción de Asistencia a la Base de Datos Exitosamente!!-------------------------------" + Environment.NewLine); writer.WriteLine("ID Empleado: " + entidad.id_empleado.ToString() + Environment.NewLine); writer.WriteLine("Número de Enrolamiento: " + entidad.numeroCredencial.ToString()); writer.WriteLine(Environment.NewLine + "-------------------------------------------------------------------------------------------" + Environment.NewLine); } } } catch (Exception ex) { EventLog.WriteEntry("Error:" + ex.Message); using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine(Environment.NewLine + "--Error de Conexión de Base de Datos-----------------------------------------" + Environment.NewLine); writer.WriteLine("Hora de Error: " + DateTime.Now + ""); writer.WriteLine("Error: " + ex.Message.ToString() + ""); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } } finally { per.CerrarConexion(); } }
public ActionResult Delete(int slno) { using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); string query = "DELETE FROM Mobiles Where SLNo = ?"; IfxCommand cmd = new IfxCommand(query, Con); cmd.Parameters.Add("slno", IfxType.Serial).Value = slno; cmd.ExecuteNonQuery(); Con.Close(); } return(RedirectToAction("Index")); }
public ActionResult Delete(int cartID) { using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); string query = "DELETE FROM Cart Where CartID = ?"; IfxCommand cmd = new IfxCommand(query, Con); cmd.Parameters.Add("cartid", IfxType.Serial).Value = cartID; cmd.ExecuteNonQuery(); Con.Close(); } return(RedirectToAction("Index")); }
/// <summary> /// Delete existing table with the same name if present /// </summary> private void DropTable() { try { _command = _connection.CreateCommand(); _command.CommandText = "drop table transactiontable"; _command.ExecuteNonQuery(); } catch (Exception excep) { WriteLine(String.Format("The particular table cannot be dropped. : {0}", excep.Message)); } }
private void zkemClient_OnAttTransactionEx(string EnrollNumber, int IsInValid, int AttState, int VerifyMethod, int Year, int Month, int Day, int Hour, int Minute, int Second, int WorkCode) { var connectionString = ConfigurationManager.ConnectionStrings["DBInformix"].ConnectionString; ip = ConfigurationManager.AppSettings["device_ip"]; using (StreamWriter writer = new StreamWriter(filePath, true)) { writer.WriteLine(" OnAttTrasactionEx Has been Triggered,Verified OK on" + "Date :" + "Enrollnumber: " + EnrollNumber + "|" + DateTime.Now.ToString()); writer.WriteLine(Environment.NewLine + "-----------------------------------------------------------------------------" + Environment.NewLine); } PerInformixDB per = new PerInformixDB(); try { checkinout entidad = new checkinout(); entidad.anio = Year; entidad.mes = Month; entidad.dia = Day; entidad.hora = Hour; entidad.minuto = Minute; entidad.segundo = Second; entidad.numeroCredencial = int.Parse(EnrollNumber); entidad.Device = ip; per.AbrirConexion(); EventLog.WriteEntry("Connection Open"); var sql = "insert into checkinout (enrollnumber,date,hour,checkinout,device) values (?,?,?,?,?);"; using (var cmd = new IfxCommand(sql, per.Conexion)) { cmd.Parameters.Add(new IfxParameter()).Value = entidad.numeroCredencial; cmd.Parameters.Add(new IfxParameter()).Value = entidad.pFecha; cmd.Parameters.Add(new IfxParameter()).Value = entidad.pHora; cmd.Parameters.Add(new IfxParameter()).Value = entidad.Ckecked; cmd.Parameters.Add(new IfxParameter()).Value = entidad.Device; cmd.ExecuteNonQuery(); } EventLog.WriteEntry("Insert EnrollNumber: " + EnrollNumber); } catch (Exception ex) { EventLog.WriteEntry("Error:" + ex.Message); } finally { per.CerrarConexion(); } }
public bool DDLOpperation(string query) { cmd = new IfxCommand(query, EcomDetailsDAL.connect()); int x = cmd.ExecuteNonQuery(); if (x == 1) { return(true); } else { return(false); } }
public bool Delete(string sql) { String _connectionString = "Server=ol_svr_custom;" + "Host=localhost;" + "Service=turbo;" + "Database=registration;" + "User ID=informix;" + "Password=123456;" + "Client Locale=ru_ru.CP1251;" + "Database Locale=ru_ru.915;" + "Max Pool Size=500;" + "Pooling=True;" + "Protocol=olsoctcp;" + "Connection Lifetime=1200;" + "Connection Timeout=1;"; try { IfxConnection _Connection = new IfxConnection() { ConnectionString = _connectionString }; _Connection.Open(); try { IfxCommand _command = new IfxCommand { Connection = _Connection, CommandText = sql }; _command.ExecuteNonQuery(); if (_Connection != null) { _Connection.Close(); } return(true); } catch { return(false); } } catch { return(false); } }
private void InsertUser(object sender, RoutedEventArgs e) { errormessage.Text = ""; int rows = 0; string insertUserSQL = "Insert into User (firstname, lastname, email, username, usertype, password, address) " + "values('" + firstname + "','" + lastname + "','" + email + "','" + username + "','" + usertype + "','" + password + "','" + address + "')"; con = new IfxConnection(cs); con.Open(); try { IfxCommand cmd = new IfxCommand(insertUserSQL, con); cmd.CommandType = CommandType.Text; rows = cmd.ExecuteNonQuery(); } catch (Exception ex) { string createTableSQL = "create table user (userid serial PRIMARY KEY, firstname varchar(20), lastname varchar(20), " + "email varchar(30), username varchar(20), usertype varchar(20), " + "password varchar(30), address varchar(150))"; IfxCommand cmd1 = new IfxCommand(createTableSQL, con); cmd1.CommandType = CommandType.Text; cmd1.ExecuteNonQuery(); IfxCommand cmd2 = new IfxCommand(insertUserSQL, con); cmd2.CommandType = CommandType.Text; rows = cmd2.ExecuteNonQuery(); } finally { con.Close(); } if (rows > 0) { if (usertype.Equals("Admin")) { errormessage.Text = "Admin registered successfully."; } else { errormessage.Text = "User registered successfully."; } } else { errormessage.Text = "Registeration failed."; } }
public IActionResult Index() { DataTable table = new DataTable(); using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); try { IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM cart", Con); ifx.Fill(table); } catch (Exception ex) { string createTable = "Create table cart (cartid serial PRIMARY KEY, SLNo int, MobileName nvarchar(100) NULL, " + " Description nvarchar(250) NULL, PicURL nvarchar(250) NULL, Model nvarchar(50) NULL, Features nvarchar(200) NULL, " + "Color nvarchar(20) NULL, SimType nvarchar(10) NULL, Price decimal(18, 2), Quantity int NULL, TotalAmount decimal(18,2))"; IfxCommand cmd = new IfxCommand(createTable, Con); cmd.ExecuteNonQuery(); IfxDataAdapter ifx = new IfxDataAdapter("SELECT * FROM cart", Con); ifx.Fill(table); } finally { Con.Close(); } } List <Cart> cartList = new List <Cart>(); for (int i = 0; i < table.Rows.Count; i++) { Cart cart = new Cart(); cart.CartID = Convert.ToInt32(table.Rows[i]["CartID"]); cart.SLNo = Convert.ToInt32(table.Rows[i]["SLNo"]); cart.MobileName = table.Rows[i]["MobileName"].ToString(); cart.Description = table.Rows[i]["Description"].ToString(); cart.PicURL = table.Rows[i]["PicURL"].ToString(); cart.Model = table.Rows[i]["Model"].ToString(); cart.Features = table.Rows[i]["Features"].ToString(); cart.Color = table.Rows[i]["Color"].ToString(); cart.SimType = table.Rows[i]["SimType"].ToString(); cart.Price = Convert.ToDecimal(table.Rows[i]["Price"]); cart.Quantity = Convert.ToInt32(table.Rows[i]["Quantity"]); cart.TotalAmount = Convert.ToDecimal(table.Rows[i]["TotalAmount"]); cartList.Add(cart); } return(View(cartList)); }
public ActionResult Create(ProductModel productModel) { using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); string query = "INSERT INTO Product (productname, price, count) VALUES(?, ?, ?)"; IfxCommand cmd = new IfxCommand(query, Con); cmd.Parameters.Add("productname", IfxType.VarChar).Value = productModel.ProductName; cmd.Parameters.Add("price", IfxType.Decimal).Value = productModel.Price; cmd.Parameters.Add("count", IfxType.Int).Value = productModel.Count; cmd.ExecuteNonQuery(); } return(RedirectToAction("Index")); }
private void insertNewOrder(IfxConnection con, OrderDetailsModel orderDetailsModel) { decimal totalamount = orderDetailsModel.Price * orderDetailsModel.Count; string query = "INSERT INTO orderdetails (productid, productname, price, count, totalamount) VALUES(?, ?, ?, ?, ?)"; IfxCommand cmd = new IfxCommand(query, con); cmd.Parameters.Add("productid", IfxType.Int).Value = orderDetailsModel.ProductID; cmd.Parameters.Add("productname", IfxType.VarChar).Value = orderDetailsModel.ProductName; cmd.Parameters.Add("price", IfxType.Decimal).Value = orderDetailsModel.Price; cmd.Parameters.Add("count", IfxType.Int).Value = orderDetailsModel.Count; cmd.Parameters.Add("totalamount", IfxType.Decimal).Value = totalamount; cmd.ExecuteNonQuery(); }
public ActionResult Edit(ProductModel productModel) { using (IfxConnection Con = new IfxConnection(connString)) { Con.Open(); string query = "UPDATE Product SET productname = ? , price= ? , count = ? Where productid = ?"; IfxCommand cmd = new IfxCommand(query, Con); cmd.Parameters.Add("productname", IfxType.VarChar).Value = productModel.ProductName; cmd.Parameters.Add("price", IfxType.Decimal).Value = productModel.Price; cmd.Parameters.Add("count", IfxType.Int).Value = productModel.Count; cmd.Parameters.Add("productid", IfxType.Serial).Value = productModel.ProductID; cmd.ExecuteNonQuery(); } return(RedirectToAction("Index")); }
/// <summary> /// Create a table /// </summary> /// <returns>bool</returns> public bool CreateTable() { try { _command = _connection.CreateCommand(); _command.CommandText = "create table transactiontable(id integer, name char(25));"; _command.ExecuteNonQuery(); } catch (Exception excep) { WriteLine(String.Format("The table cannot be created: {0}", excep.Message)); return(false); } return(true); }
public bool Insert(EmpleadoHuella entidad) { bool respuesta = false; try { var sql = string.Empty; AbrirConexion(); sql = "execute procedure dml_empleado_huella (?,NULL,?,?,?,?,?,?);"; using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "INSERT"; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_empleado; if (entidad.huella != null) { cmd.Parameters.Add(new IfxParameter()).Value = entidad.huella; } cmd.Parameters.Add(new IfxParameter()).Value = entidad.enrollnumber; cmd.Parameters.Add(new IfxParameter()).Value = entidad.fingerIndex; cmd.Parameters.Add(new IfxParameter()).Value = entidad.flag; cmd.Parameters.Add(new IfxParameter()).Value = entidad.tmplength; cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insert Huella"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insert Huella"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
public bool Update(EntTurno entidad) { bool respuesta = false; try { AbrirConexion(); var sql = "execute procedure dml_turno (?,?,?,?,?,?,?,?,?,?,?);"; using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "UPDATE"; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_turno; cmd.Parameters.Add(new IfxParameter()).Value = entidad.desc_turno; cmd.Parameters.Add(new IfxParameter()).Value = entidad.domingo; cmd.Parameters.Add(new IfxParameter()).Value = entidad.lunes; cmd.Parameters.Add(new IfxParameter()).Value = entidad.martes; cmd.Parameters.Add(new IfxParameter()).Value = entidad.miercoles; cmd.Parameters.Add(new IfxParameter()).Value = entidad.jueves; cmd.Parameters.Add(new IfxParameter()).Value = entidad.viernes; cmd.Parameters.Add(new IfxParameter()).Value = entidad.sabado; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_horario; cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Turnos"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Turnos"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
public bool Update(EntEnrolamiento entidad) { bool respuesta = false; try { var sql = string.Empty; AbrirConexion(); sql = "execute procedure dml_enrolamiento (?,?,?,?,?);"; using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "UPDATE"; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_enrolamiento; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_empleado; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_dispositivo; cmd.Parameters.Add(new IfxParameter()).Value = entidad.enrollnumber; cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Actualizar Enrrolamiento"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Actualizar Enrrolamiento"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
public bool Update(EntUsuario entidad) { bool respuesta = false; try { AbrirConexion(); var sql = "execute procedure dml_usuarios (?,?,?,?,?,?,?,?);"; using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Connection = Conexion; cmd.Parameters.Add(new IfxParameter()).Value = "UPDATE"; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_usuario; cmd.Parameters.Add(new IfxParameter()).Value = entidad.usuario; cmd.Parameters.Add(new IfxParameter()).Value = entidad.password; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_rol; cmd.Parameters.Add(new IfxParameter()).Value = entidad.activo; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_empresa; cmd.Parameters.Add(new IfxParameter()).Value = entidad.nombre; cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Usuarios"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Update Usuarios"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
public bool Insert(Checkinout entidad) { bool respuesta = false; try { AbrirConexion(); var sql = "insert into asistencia (id_empleado,date,hour,checkinout,device,id_sucursal,enrollnumber) values (?,?,?,?,?,?,NULL);"; using (var cmd = new IfxCommand(sql, Conexion)) { cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_empleado; cmd.Parameters.Add(new IfxParameter()).Value = entidad.pFecha; cmd.Parameters.Add(new IfxParameter()).Value = entidad.pHora; cmd.Parameters.Add(new IfxParameter()).Value = entidad.Ckecked; cmd.Parameters.Add(new IfxParameter()).Value = entidad.Device; cmd.Parameters.Add(new IfxParameter()).Value = entidad.id_sucursal; cmd.ExecuteNonQuery(); } respuesta = true; } catch (InvalidCastException ex) { ApplicationException excepcion = new ApplicationException("Se genero un error con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insert Checkinout"; throw excepcion; } catch (Exception ex) { ApplicationException excepcion = new ApplicationException("Se genero un error de aplicación con el siguiente mensaje: " + ex.Message, ex); excepcion.Source = "Insert Checkinout"; throw excepcion; } finally { CerrarConexion(); } return(respuesta); }
private void insertNewOrder(IfxConnection con, MyOrders order) { string query = "INSERT INTO orderdetails (purchasedate, slno, mobilename, description, picurl, model, features, color, simtype, price, quantity, totalamount)" + " VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; IfxCommand cmd = new IfxCommand(query, con); cmd.Parameters.Add("purchasedate", IfxType.DateTime).Value = order.PurchaseDate; cmd.Parameters.Add("slno", IfxType.Int).Value = order.SLNo; cmd.Parameters.Add("mobilename", IfxType.VarChar).Value = order.MobileName; cmd.Parameters.Add("description", IfxType.VarChar).Value = order.Description; cmd.Parameters.Add("picurl", IfxType.VarChar).Value = order.PicURL; cmd.Parameters.Add("model", IfxType.VarChar).Value = order.Model; cmd.Parameters.Add("features", IfxType.VarChar).Value = order.Features; cmd.Parameters.Add("color", IfxType.VarChar).Value = order.Color; cmd.Parameters.Add("simtype", IfxType.VarChar).Value = order.SimType; cmd.Parameters.Add("price", IfxType.Decimal).Value = order.Price; cmd.Parameters.Add("quantity", IfxType.Int).Value = order.Quantity; cmd.Parameters.Add("totalamount", IfxType.Decimal).Value = order.TotalAmount; cmd.ExecuteNonQuery(); }
/// <summary> /// Execute des requêtes INSERT / UPDATE / DELETE /// </summary> /// <param name="sqlQuery"></param> /// <returns></returns> public int ExecuteNonQuery(string sqlQuery) { lock (this.dbConnexion) { int returnValue = -1; if (this.options.ConnexionODBC == true) { OdbcCommand odbcCommand = new OdbcCommand(sqlQuery, (this.dbConnexion as OdbcConnection)); returnValue = odbcCommand.ExecuteNonQuery(); } else { if (this.typeBase == Type.Informix) { IfxCommand ifxCommand = new IfxCommand(sqlQuery, (this.dbConnexion as IfxConnection)); returnValue = ifxCommand.ExecuteNonQuery(); } else if (this.typeBase == Type.SQLServer) { SqlCommand sqlCommand = new SqlCommand(sqlQuery, (this.dbConnexion as SqlConnection)); returnValue = sqlCommand.ExecuteNonQuery(); } } return returnValue; } }