private void Medicamentos_Load(object sender, EventArgs e) { DateTime fecha = DateTime.Now; int margenDias = fecha.Day - 15; //DateTime margenFecha = DateTime.Parse(string.Format("{0}/{1}/{2} {3}:{4}:{5}", margenDias, fecha.Month, fecha.Year, fecha.Hour, fecha.Minute, fecha.Second)); DateTime margenFecha = new DateTime(fecha.Year, fecha.Month-1, fecha.Day); editar = false; if(Inicio.User!="Admin") { btnNew.Enabled = false; btnDelete.Enabled = false; btnEditar.Enabled = false; } med.ActualizarGrid(this.dataGridView1, "select * from Medicamentos"); ConexionBD conn = new ConexionBD("Medicamentos"); conn.Conectar(); conn.Comparacion(string.Format("select * from Medicamentos where FechCad <= '{0}'", margenFecha)); }
public int InsertReference(string codigoUbicacion, string codigoBarras, string codigoBarrasIC, string descripcionItem, int id_Marca, int grupo, int cantidad, string imagen, string proyecto, string equivalencias, bool existe, string color) { int existReference = SelectLikeReferenceCod2(codigoBarras); var equivalenciasSave = equivalencias.Split(','); var LengthqEquivalence = equivalenciasSave.Length; SqlCommand comando = ConexionBD.crearcomandoInventario(); if (!existe) { if (equivalencias == null || equivalencias == "undefined" || equivalencias == "") { if (existReference > 0) { comando.CommandText = "INSERT INTO Ubicacion(codigoUbicacion,CodigoProyecto) VALUES('" + codigoUbicacion + "','" + proyecto + "') " + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + codigoBarras + "'," + cantidad + ")"; } else { comando.CommandText = "INSERT INTO Ubicacion(codigoUbicacion,CodigoProyecto) VALUES('" + codigoUbicacion + "','" + proyecto + "') " + "INSERT INTO ReferenciasCodBarras(codigoBarras,codigoBarrasIC,descripcionItem,id_Marca,grupo,imagen,color) VALUES('" + codigoBarras + "','" + codigoBarrasIC + "','" + descripcionItem + "'," + id_Marca + "," + grupo + ",'" + imagen + "', '" + color + "') " + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + codigoBarras + "'," + cantidad + ")"; } } else { if (existReference > 0) { comando.CommandText = "INSERT INTO Ubicacion(codigoUbicacion,CodigoProyecto) VALUES('" + codigoUbicacion + "','" + proyecto + "') " + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + codigoBarras + "'," + cantidad + ")"; for (var i = 0; i < LengthqEquivalence; i++) { var equivalenceshort = equivalenciasSave[i].Split('.'); var equivalenceshortsend = equivalenceshort[equivalenceshort.Length - 1]; int equivalenceInsert = LikeReferenceInsert(equivalenceshortsend); int equivalenceIconstruye = LikeReferenceInsertIC(equivalenciasSave[i]); if (equivalenceInsert <= 0 && equivalenceIconstruye <= 0) { comando.CommandText = comando.CommandText + "INSERT INTO ReferenciasCodBarras VALUES('','" + equivalenceshortsend + "'," + 1 + ",'" + descripcionItem + "'," + grupo + ",'','verde')" + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + equivalenceshortsend + "'," + 0 + ")"; } int existElength = ExistReference(codigoBarras, equivalenceshortsend); if (existElength <= 0) { comando.CommandText = comando.CommandText + "INSERT INTO Equivalencias(codigoBarras,codigoItem) VALUES('" + codigoBarras + "','" + equivalenceshortsend + "')"; } } } else { comando.CommandText = "INSERT INTO Ubicacion(codigoUbicacion,CodigoProyecto) VALUES('" + codigoUbicacion + "','" + proyecto + "') " + "INSERT INTO ReferenciasCodBarras(codigoBarras,codigoBarrasIC,descripcionItem,id_Marca,grupo,imagen,color) VALUES('" + codigoBarras + "','" + codigoBarrasIC + "','" + descripcionItem + "'," + id_Marca + "," + grupo + ",'" + imagen + "', '" + color + "') " + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + codigoBarras + "'," + cantidad + ")"; for (var i = 0; i < LengthqEquivalence; i++) { var equivalenceshort = equivalenciasSave[i].Split('.'); var equivalenceshortsend = equivalenceshort[equivalenceshort.Length - 1]; int equivalenceInsert = LikeReferenceInsert(equivalenceshortsend); int equivalenceIconstruye = LikeReferenceInsertIC(equivalenciasSave[i]); if (equivalenceInsert <= 0 && equivalenceIconstruye <= 0) { comando.CommandText = comando.CommandText + "INSERT INTO ReferenciasCodBarras VALUES('','" + equivalenceshortsend + "'," + 1 + ",'" + descripcionItem + "'," + grupo + ",'','verde')" + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + equivalenceshortsend + "'," + 0 + ")"; } comando.CommandText = comando.CommandText + "INSERT INTO Equivalencias(codigoBarras,codigoItem) VALUES('" + codigoBarras + "','" + equivalenceshortsend + "')"; } } } } else { if (equivalencias == null || equivalencias == "undefined" || equivalencias == "") { if (existReference > 0) { comando.CommandText = "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + codigoBarras + "'," + cantidad + ")"; } else { comando.CommandText = "INSERT INTO ReferenciasCodBarras(codigoBarras,codigoBarrasIC,descripcionItem,id_Marca,grupo,imagen,color) VALUES('" + codigoBarras + "','" + codigoBarrasIC + "','" + descripcionItem + "'," + id_Marca + "," + grupo + ",'" + imagen + "', '" + color + "') " + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + codigoBarras + "'," + cantidad + ")"; } } else { if (existReference > 0) { comando.CommandText = "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + codigoBarras + "'," + cantidad + ")"; for (var i = 0; i < LengthqEquivalence; i++) { var equivalenceshort = equivalenciasSave[i].Split('.'); var equivalenceshortsend = equivalenceshort[equivalenceshort.Length - 1]; int equivalenceInsert = LikeReferenceInsert(equivalenceshortsend); int equivalenceIconstruye = LikeReferenceInsertIC(equivalenciasSave[i]); if (equivalenceInsert <= 0 && equivalenceIconstruye <= 0) { comando.CommandText = comando.CommandText + "INSERT INTO ReferenciasCodBarras VALUES('','" + equivalenceshortsend + "'," + 1 + ",'" + descripcionItem + "'," + grupo + ",'','verde')" + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + equivalenceshortsend + "'," + 0 + ")"; } int existElength = ExistReference(codigoBarras, equivalenceshortsend); if (existElength <= 0) { comando.CommandText = comando.CommandText + "INSERT INTO Equivalencias(codigoBarras,codigoItem) VALUES('" + codigoBarras + "','" + equivalenceshortsend + "')"; } } } else { comando.CommandText = "INSERT INTO ReferenciasCodBarras(codigoBarras,codigoBarrasIC,descripcionItem,id_Marca,grupo,imagen,color) VALUES('" + codigoBarras + "','" + codigoBarrasIC + "','" + descripcionItem + "'," + id_Marca + "," + grupo + ",'" + imagen + "', '" + color + "') " + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + codigoBarras + "'," + cantidad + ")"; for (var i = 0; i < LengthqEquivalence; i++) { var equivalenceshort = equivalenciasSave[i].Split('.'); var equivalenceshortsend = equivalenceshort[equivalenceshort.Length - 1]; int equivalenceInsert = LikeReferenceInsert(equivalenceshortsend); int equivalenceIconstruye = LikeReferenceInsertIC(equivalenciasSave[i]); if (equivalenceInsert <= 0 && equivalenceIconstruye <= 0) { comando.CommandText = comando.CommandText + "INSERT INTO ReferenciasCodBarras VALUES('','" + equivalenceshortsend + "'," + 1 + ",'" + descripcionItem + "'," + grupo + ",'','verde')" + "INSERT INTO NUbicacionXReferenciaCB(codigoUbicacion,CodigoBarras,cantidad) VALUES('" + codigoUbicacion + "','" + equivalenceshortsend + "'," + 0 + ")"; } comando.CommandText = comando.CommandText + "INSERT INTO Equivalencias(codigoBarras,codigoItem) VALUES('" + codigoBarras + "','" + equivalenceshortsend + "')"; } } } } return(ConexionBD.EjecutarComando(comando)); }