private void edit_mostrarDatos_lote() { try { string errores = ""; string rpta = ""; ConsultaSql = ConsultaSql + " EXEC MONEDAEQUIVALENTE '" + idpresupuesto + "'"; ConsultaSql = ConsultaSql + " EXEC ACTUALIZA_MONEDA_PRTLOTE '" + idpresupuesto + "'"; rpta = NFunciones.ExecuteSQL(ConsultaSql); if (!rpta.Equals("Ok")) { errores = "Se produjo un error consulte con soporte"; Console.Write(errores); } ConsultaSql = ""; tbgeneral = NFunciones.TABLADATOS("EXEC sp_FiltroPresupuesto_Lote '" + idpresupuesto + "','" + Convert.ToString(cbo_cultivo.EditValue).Trim() + "','" + Convert.ToString(cbo_variedad.EditValue).Trim() + "','" + Convert.ToString(cbo_estructura.EditValue).Trim() + "','" + Convert.ToString(cbo_item.EditValue).Trim() + "','" + Convert.ToString(cbo_fundo.EditValue).Trim() + "','" + Convert.ToString(cbo_actisub.EditValue).Trim() + "','" + Convert.ToString(cbo_labor.EditValue).Trim() + "','" + Convert.ToString(cbo_moneda.EditValue).Trim() + "','" + Convert.ToString(cbo_lote.EditValue).Trim() + "'"); modo = "S"; } catch (Exception ex) { MensajeError("Ocurrio un error, Consulte con Soporte" + "\n" + ex.Message); modo = "S"; } }
private void btn_eliminar_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { DialogResult rpta = MessageBox.Show("Desea Eliminar este registro ?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (rpta == DialogResult.Yes) { DataTable tb_op = new DataTable(); tb_op = NFunciones.TABLASQL("select * from tb_docreferencia where idempresa='" + VariablesGenerales.Empresa + "' and idorigen='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "'"); if (tb_op.Rows.Count > 0) { MessageBox.Show("No se Puede Eliminar el Documento esta Referenciado a otro Documento ", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { string eliminarcabecera = NFunciones.ExecuteSQL("DELETE tb_cobrarpagardoc WHERE IDEMPRESA='" + VariablesGenerales.Empresa + "' AND idcobrarpagardoc='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "'"); string detalle = NFunciones.ExecuteSQL("DELETE tb_dcobrarpagardoc WHERE IDEMPRESA='" + VariablesGenerales.Empresa + "' AND idcobrarpagardoc='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "'"); string mov = NFunciones.ExecuteSQL("DELETE tb_movcobrarpagardoc_drakback WHERE IDEMPRESA='" + VariablesGenerales.Empresa + "' AND idcobrarpagardoc='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "' AND IDTRANSACCION='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "'"); LlegarGrilla(); MessageBox.Show("Se Elimino Correctamente", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch { MessageBox.Show("Elija un registro ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
void Insertando() { //VARIABLES A SUBIR //cabecera string iidcobrarpagardoc, idempresa, iddocumento, serie, numero, idclieprov, razonsocial, estado, tipo, idmoneda; DateTime fecha; //detalle string idempresa_det, idcobrarpagar_det, item, idproducto_det, descripcion_det, idunidad_det; double cantidad_det, porc_imp, imp, precio_unit, preciototal, tc; string error = ""; int correlativo = 0; foreach (DataRow row in dtlote.Rows) { correlativo = correlativo + 1; string id = "V" + DateTime.Now.Date.Day.ToString() + DateTime.Now.Date.Month.ToString() + DateTime.Now.Date.Year.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Second.ToString() + DateTime.Now.Millisecond.ToString() + VariablesGenerales.Empresa + Convert.ToString(correlativo); string rpta = NFunciones.ExecuteSQL("EXEC INSERT_VENTAS '" + id + "','" + VariablesGenerales.Empresa + "','" + row[1].ToString() + "','" + row[2].ToString() + "','" + row[3].ToString() + "','" + row[4].ToString() + "','" + row[5].ToString() + "','" + row[6].ToString() + "','" + row[7].ToString() + "','" + row[9].ToString() + "','" + row[10].ToString() + "','" + row[12].ToString() + "'"); if (!rpta.Equals("Ok")) { error = "Error de registro :" + row[1].ToString() + " " + row[2].ToString() + "-" + row[3].ToString() + "\n"; } } if (!string.IsNullOrEmpty(error)) { MessageBox.Show("Tiene los siguientes errores :" + error); } else { MessageBox.Show("Importado Correctamente"); } }
private void btn_eliminar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (!this.txt_codigo.Text.Equals("")) { string rpta = ""; try { DialogResult Opcion; Opcion = MessageBox.Show("Realmente Desea Eliminar este registro", "Presupuesto", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (Opcion == DialogResult.OK) { rpta = NFunciones.ExecuteSQL(" DELETE P_FUNDO WHERE IDFUNDO='" + txt_codigo.Text + "'"); if (rpta.Equals("Ok")) { this.MensajeOk("Eliminado Correctamente"); this.Limpiar(); } else { this.MensajeError(rpta); } } } catch (Exception ex) { this.MensajeError(ex.Message + ex.StackTrace); } this.llenargrilla(); } }
private void btn_eliminar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { DataTable validar = NFunciones.TABLASQL("select * from tb_dcobrarpagardoc d inner join tb_productos p on p.idproducto=d.idproducto and p.idempresa=d.idempresa where p.idempresa='" + VariablesGenerales.Empresa + "' and p.idgrupopro='" + txt_codigo.Text + "'"); if (validar.Rows.Count > 0) { MessageBox.Show("No se Puede Eliminar Ya que esta registrado en productos con movimiento !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { DialogResult respuesta = MessageBox.Show("Esta Seguro de eliminar el registro ?", "Confimación", MessageBoxButtons.OK, MessageBoxIcon.Question); if (respuesta == DialogResult.OK) { string delete = NFunciones.ExecuteSQL("delete tb_grupopro where idempresa='" + VariablesGenerales.Empresa + "' and idgrupopro='" + txt_codigo.Text + "'"); if (delete.Equals("Ok")) { MessageBox.Show("Registro Eliminado!", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); LlegarGrilla(); limpiartxt(); } else { MessageBox.Show("No se puedo realizar la Operacion !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } }
private void btn_eliminar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { DialogResult rpta = MessageBox.Show("Desea Eliminar este registro ?", "Alerta", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (rpta == DialogResult.Yes) { DataTable tbdua = NFunciones.TABLASQL("SELECT * FROM TB_DUA WHERE IDDUA='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "' AND IDEMPRESA='" + VariablesGenerales.Empresa + "'"); string cabecera = NFunciones.ExecuteSQL("delete tb_dua where iddua='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "'and idempresa='" + VariablesGenerales.Empresa + "'"); string referencia = NFunciones.ExecuteSQL("delete tb_docreferencia where idempresa='" + VariablesGenerales.Empresa + "' and iddestino='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "'"); // insertar exportacion string exportacion = NFunciones.ExecuteSQL("update tb_dcobrarpagardoc set idref='NULL' where idcobrarpagardoc='" + tbdua.Rows[0]["idcobrarpagardoc"].ToString() + "'"); //insertar insumos string deleteinsumos = NFunciones.ExecuteSQL("delete tb_movcobrarpagardoc_drakback where idtransaccion='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "' and idempresa='" + VariablesGenerales.Empresa + "'"); VariablesGenerales.refduas = "S"; MessageBox.Show("Dua eliminada", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); } } catch { MessageBox.Show("Elija un registro ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { string rpta = ""; if (this.txt_codigo.Text == string.Empty) { MensajeError("Falta Ingresar Codigo"); return; } if (this.txt_descripcion.Text == string.Empty) { MensajeError("Falta Ingresar Nombre de Responsable"); return; } string codigo; DataTable dtid = new DataTable(); if (this.IsNuevo) { dtid = NFunciones.TABLADATOS("EXEC SP_IDRESPONSABLE''"); codigo = dtid.Rows[0]["ID"].ToString(); txt_codigo.Text = codigo; rpta = NFunciones.ExecuteSQL("INSERT INTO P_RESPONSABLES(IdResponsable,Nombre,ESTADO) values('" + codigo + "','" + txt_descripcion.Text + "','AC')"); } else { rpta = NFunciones.ExecuteSQL("UPDATE P_RESPONSABLES set NOMBRE='" + txt_descripcion.Text + "' WHERE IDRESPONSABLE='" + txt_codigo.Text + "'"); } if (rpta.Equals("Ok")) { if (this.IsNuevo) { this.MensajeOk("Se Inserto los Datos Correctamente"); } else { this.MensajeOk("Se Actualizo los Datos Correctamente"); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.HabilitarTexbox(false); this.LlenarGrilla(); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
void procesar() { DataTable _dtresultado; _dtresultado = NFunciones.TABLADATOS("EXEC SP_PROCESAR_PXQ '" + _idpresupuesto + "'"); string rpta = NFunciones.ExecuteSQL("EXEC SP_CALCULAR_PYG'" + _idpresupuesto + "'"); estado = "S"; }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (txt_codigo.Text.Equals("")) { MessageBox.Show("Debe Ingresar Codigo !"); return; } if (txt_descripcion.Text.Equals("")) { MessageBox.Show("Debe Ingresar Descripcion !"); return; } //if (txt_valor.Text.Equals("")) //{ // MessageBox.Show("Debe Ingresar Valor !"); // return; //} //if (txt_sp.Text.Equals("")) //{ // MessageBox.Show("Debe Ingresar SP Asignado !"); // return; //} if (_modo.Equals("N")) { DataTable tb_table = new DataTable(); tb_table = NFunciones.TABLADATOS("SELECT * FROM P_PARAMETROS WHERE IDVARIABLE='" + txt_codigo.Text + "'"); if (tb_table.Rows.Count > 0) { MessageBox.Show("Ya existe el codigo ingresado debe colocar uno que nuevo !"); return; } string rpta = NFunciones.ExecuteSQL("INSERT INTO P_PARAMETROS (IDEMPRESA,IDVARIABLE,DESCRIPCION,VALOR,SP_ASIGNADO)VALUES('001','" + txt_codigo.Text + "','" + txt_descripcion.Text + "','" + txt_valor.Text + "','" + txt_sp.Text + "')"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Guardado Correctamente"); } } if (_modo.Equals("E")) { string rpta = NFunciones.ExecuteSQL("UPDATE P_PARAMETROS SET DESCRIPCION='" + txt_descripcion.Text + "',VALOR='" + txt_valor.Text + "', SP_ASIGNADO='" + txt_sp.Text + "' WHERE IDVARIABLE='" + txt_codigo.Text + "'"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Actualizado Correctamente"); } } _modo = ""; }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (txt_codigo.Text.Equals("")) { MessageBox.Show("Debe Ingresar Codigo de Empresa !"); return; } if (txt_razonsocial.Text.Equals("")) { MessageBox.Show("Debe Ingresar Razon Social !"); return; } //if (txt_ruc.Text.Equals("")) //{ // MessageBox.Show("Debe Ingresar Ruc!"); // return; //} if (cbo_tipo.Text.Equals("[Seleccionar]")) { MessageBox.Show("Debe Ingresar Tipo Empresa !"); return; } if (_modo.Equals("N")) { DataTable tb_table = new DataTable(); tb_table = NFunciones.TABLASQL("select idclieprov from tb_clieprov where idclieprov='" + txt_codigo.Text + "' and idempresa='" + VariablesGenerales.Empresa + "'"); if (tb_table.Rows.Count > 0) { MessageBox.Show("Ya existe el codigo ingresado debe colocar uno que nuevo !"); return; } string rpta = NFunciones.ExecuteSQL("insert into tb_clieprov(idempresa,idclieprov,razonsocial,ruc,tipoclieprov,estado) values('" + VariablesGenerales.Empresa + "','" + txt_codigo.Text.ToUpper() + "','" + txt_razonsocial.Text.ToUpper() + "','" + txt_ruc.Text.ToUpper() + "','" + cbo_tipo.EditValue.ToString() + "','1')"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Guardado Correctamente"); } } if (_modo.Equals("E")) { string rpta = NFunciones.ExecuteSQL("update tb_clieprov set razonsocial='" + txt_razonsocial.Text.ToUpper() + "',ruc='" + txt_ruc.Text.ToUpper() + "',tipoclieprov='" + cbo_tipo.EditValue.ToString() + "' where idempresa='" + VariablesGenerales.Empresa + "' and idclieprov='" + txt_codigo.Text.ToUpper() + "'"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Actualizado Correctamente"); } } }
private void ProcesarConsultar() { string rpta = NFunciones.ExecuteSQL("EXEC SP_CALCULAR_PYG_DOL'" + idpresupuesto + "','" + idmoneda + "'"); dtresultado = NFunciones.TABLADATOS(" EXEC SP_REPORTE_PYG'" + idpresupuesto + "','" + idmoneda + "','" + idfundo + "','" + idcultivo + "'"); mostrar = "S"; }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (cbo_grupo.Text.Equals("[Seleccionar]")) { MessageBox.Show("Debe seleccionar Grupo !"); return; } if (txt_codigo.Text.Equals("")) { MessageBox.Show("Debe Ingresar Codigo !"); return; } if (txt_razonsocial.Text.Equals("")) { MessageBox.Show("Debe Ingresar Descripcion de Grupo !"); return; } if (_modo.Equals("N")) { DataTable tb_table = new DataTable(); tb_table = NFunciones.TABLASQL("SELECT * FROM tb_subgrupo WHERE idempresa='" + VariablesGenerales.Empresa + "' AND idgrupopro='" + txt_codigo.Text + "'"); if (tb_table.Rows.Count > 0) { MessageBox.Show("Ya existe el codigo ingresado debe colocar uno que nuevo !"); return; } string rpta = NFunciones.ExecuteSQL("insert into tb_subgrupo(idempresa,idsubgrupopro,idgrupopro,descripcion,estado) values('" + VariablesGenerales.Empresa + "','" + txt_codigo.Text + "','" + cbo_grupo.EditValue.ToString() + "','" + txt_razonsocial.Text + "','1')"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); _modo = ""; MessageBox.Show("Guardado Correctamente"); } } if (_modo.Equals("E")) { string rpta = NFunciones.ExecuteSQL("update tb_subgrupo set descripcion='" + txt_razonsocial.Text + "' where idempresa='" + VariablesGenerales.Empresa + "' and idgrupopro='" + cbo_grupo.EditValue.ToString() + "'"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); _modo = ""; MessageBox.Show("Actualizado Correctamente"); } } }
private void Consultar() { DataTable tbregistros = new DataTable(); tbregistros = NFunciones.TABLADATOS("SELECT COUNT(*)NREGISTROS FROM P_RPT_PYG WHERE IDPRESUPUESTO='" + idpresupuesto + "'"); if (Convert.ToInt32(tbregistros.Rows[0]["NREGISTROS"]) == 0) { string rpta = NFunciones.ExecuteSQL("EXEC SP_CALCULAR_PYG_DOL'" + idpresupuesto + "','" + idmoneda + "'"); } dtresultado = NFunciones.TABLADATOS(" EXEC SP_REPORTE_PYG'" + idpresupuesto + "','" + idmoneda + "','" + valores + "','" + cultivos + "'"); mostrar = "S"; }
void actualizardatos() { if (TC > 0) { string rptat2 = NFunciones.ExecuteSQL("UPDATE P_PARAMETROS SET VALOR='" + Convert.ToDecimal(txt_tipocambio.Text) + "' WHERE IDVARIABLE='001' "); if (rptat2.Equals("Ok")) { toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[0]); } else { toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[1]); } } if (!idpresupuesto.Equals("")) { try { DataTable tbractualiza, tbractualiza1, tbractualiza2 = new DataTable(); string rpta, rpta1, rpta2; tbractualiza = NFunciones.TABLADATOS("EXEC ACTUALIZA_MONEDA_PRTLOTE'" + idpresupuesto + "'"); rpta = tbractualiza.Rows[0]["RESULTADO"].ToString(); tbractualiza1 = NFunciones.TABLADATOS("EXEC SP_PROCESAR_PXQ_DOL'" + idpresupuesto + "','02'"); tbractualiza2 = NFunciones.TABLADATOS("EXEC SP_PROCESAR_PXQ_SOL'" + idpresupuesto + "','01'"); MessageBox.Show(rpta + " " + Convert.ToString(tbractualiza1.Rows.Count) + " " + Convert.ToString(tbractualiza2.Rows.Count)); if (rpta.Equals("Ok") /*&& tbractualiza1.Rows.Count>0 && tbractualiza2.Rows.Count > 0*/) { //MessageBox.Show("Correctamente actualizado"); toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[2]); } else { toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[3]); } // MessageBox.Show(rpta); } catch (Exception ex) { MessageBox.Show(ex.Message); // toastNotificationsManager1.Notifications[4].Body2 = EX.Message; toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[3]); } } actualizar = "S"; }
private void btn_activar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { string estado; if (vista_registros.GetFocusedRowCellValue(COL_IDESTADO).ToString().Equals("1")) { estado = "ANULAR"; } else { estado = "ACTIVAR"; } DialogResult resultado; resultado = MessageBox.Show("Desea " + estado + " el registro ?", "Advertencia", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (resultado == DialogResult.Yes) { string respuesta; if (vista_registros.GetFocusedRowCellValue(COL_IDESTADO).ToString().Equals("1")) { respuesta = NFunciones.ExecuteSQL("UPDATE P_PARAMETROS_ESPECIFICOS SET IDESTADO='0' WHERE ID='" + vista_registros.GetFocusedRowCellValue(COL_ID).ToString() + "' "); } else { DataTable TB_VERIFICACION = NFunciones.TABLADATOS("SELECT * FROM P_PARAMETROS_ESPECIFICOS WHERE IDVARIEABLE='" + vista_registros.GetFocusedRowCellValue(COL_IDVARIABLE).ToString() + "' AND IDPRESUPUESTO='" + vista_registros.GetFocusedRowCellValue(COL_IDPRESUPUESTO).ToString() + "' AND IDESTADO='1'"); if (TB_VERIFICACION.Rows.Count > 0) { MessageBox.Show("NO se Puede Activar , Ya existe un registro para esta Variable y Presupuesto", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { respuesta = NFunciones.ExecuteSQL("UPDATE P_PARAMETROS_ESPECIFICOS SET IDESTADO='1' WHERE ID='" + vista_registros.GetFocusedRowCellValue(COL_ID).ToString() + "' "); } } if (respuesta.Equals("Ok")) { MessageBox.Show("Se Actualizo Correctamente ", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No se Pudo Actualizar!! ", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); } LlegarGrilla(); } }
private void btn_eliminar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { DataTable tb_op = new DataTable(); if (txt_idoperacion.Text.Equals("C")) { tb_op = NFunciones.TABLASQL("SELECT * FROM tb_movcobrarpagardoc_drakback where idcobrarpagardoc='" + txt_id.Text + "' and idempresa='" + VariablesGenerales.Empresa + "' and not idtransaccion='" + txt_id.Text + "'"); } if (txt_idoperacion.Text.Equals("V")) { tb_op = NFunciones.TABLASQL("select * from tb_docreferencia where idempresa='" + VariablesGenerales.Empresa + "' and idorigen='" + txt_id.Text + "'"); } if (tb_op.Rows.Count > 0) { MessageBox.Show("No se Puede Eliminar el Documento esta Referenciado a otro Documento ", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { DialogResult Result = MessageBox.Show("Esta Seguro de Eliminar el Documento", "Verificación !", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (Result == DialogResult.Yes) { string eliminarcabecera = NFunciones.ExecuteSQL("DELETE tb_cobrarpagardoc WHERE IDEMPRESA='" + VariablesGenerales.Empresa + "' AND idcobrarpagardoc='" + txt_id.Text + "'"); string detalle = NFunciones.ExecuteSQL("DELETE tb_dcobrarpagardoc WHERE IDEMPRESA='" + VariablesGenerales.Empresa + "' AND idcobrarpagardoc='" + txt_id.Text + "'"); string mov = NFunciones.ExecuteSQL("DELETE tb_movcobrarpagardoc_drakback WHERE IDEMPRESA='" + VariablesGenerales.Empresa + "' AND idcobrarpagardoc='" + txt_id.Text + "' AND IDTRANSACCION='" + txt_id.Text + "'"); limpiartxt(); txt_id.Text = ""; LlegarGrilla(); MessageBox.Show("Se Elimino Correctamente", "Confirmación", MessageBoxButtons.OK, MessageBoxIcon.Information); if (txt_idoperacion.Text.Equals("C")) { VariablesGenerales.refrescompras = "S"; } if (txt_idoperacion.Text.Equals("V")) { VariablesGenerales.refresventas = "S"; } } else { return; } } }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (txt_codigo.Text.Equals("")) { MessageBox.Show("Debe Ingresar Codigo !"); return; } if (txt_razonsocial.Text.Equals("")) { MessageBox.Show("Debe Ingresar Descripcion de Grupo !"); return; } if (_modo.Equals("N")) { DataTable tb_table = new DataTable(); tb_table = NFunciones.TABLASQL("select idgrupopro from tb_grupopro where idgrupopro='" + txt_codigo.Text + "' and idempresa='" + VariablesGenerales.Empresa + "'"); if (tb_table.Rows.Count > 0) { MessageBox.Show("Ya existe el codigo ingresado debe colocar uno que nuevo !"); return; } string rpta = NFunciones.ExecuteSQL("INSERT INTO tb_grupopro (idempresa,idgrupopro,descripcion,estado) VALUES('" + VariablesGenerales.Empresa + "','" + txt_codigo.Text + "','" + txt_razonsocial.Text + "','1')"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Guardado Correctamente"); } } if (_modo.Equals("E")) { string rpta = NFunciones.ExecuteSQL("update tb_grupopro set descripcion='" + txt_razonsocial.Text + "' where idempresa='" + VariablesGenerales.Empresa + "' and idgrupopro='" + txt_codigo.Text + "'"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Actualizado Correctamente"); } } _modo = ""; }
private void Actualizardatos() { if (!_idpresupuesto.Equals("")) { try { string rpta; rpta = NFunciones.ExecuteSQL("EXEC SP_GENERAR_RPTXLOTE'" + _idpresupuesto + "'"); toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[2]); } catch { toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[2]); } } _actualizar = "S"; }
private void Actualizardatos() { var rpta = NFunciones.ExecuteSQL("EXEC SP_GENERA_SEMANAS'" + Convert.ToString(cbo_presupuesto.EditValue) + "' "); if (rpta.Equals("Ok")) { // VariablesGenerales.idalerta = "989b838b-d806-4edf-a594-e5ecb79d2512"; //VariablesGenerales.mostraralerta = "S"; //MessageBox.Show("Actualizado Correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[0]); _actualizar = "S"; } else { toastNotificationsManager1.ShowNotification(toastNotificationsManager1.Notifications[1]); // MessageBox.Show("No se puedo actualizar Correctamente", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); _actualizar = "S"; } }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (txt_id.Text.Equals("")) { MessageBox.Show("Debe Ingresar Id !"); return; } if (txt_descripcion.Text.Equals("")) { MessageBox.Show("Debe Ingresar Descripción!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cbo_presupuesto.Text.Equals("[Seleccionar]")) { MessageBox.Show("Debe seleccionar Presupuesto !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cbo_variable.Text.Equals("[Seleccionar]")) { MessageBox.Show("Debe seleccionar Variable !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_sp.Text.Equals("")) { MessageBox.Show("Debe Ingresar SP_QUERY!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_detalle.RowCount < 1) { MessageBox.Show("Debe ingresar detalle !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { for (int i = 0; i < vista_detalle.RowCount; i++) { if (vista_detalle.GetRowCellValue(i, IDFUNDO) == null) { MessageBox.Show("Debe ingresar Fundo !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_detalle.GetRowCellValue(i, IDCULTIVO) == null) { MessageBox.Show("Debe ingresar Cultivo !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_detalle.GetRowCellValue(i, VALOR) == null) { MessageBox.Show("Debe ingresar Valor !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } } if (_modo.Equals("N")) { DataTable TB_VERIFICACION = NFunciones.TABLADATOS("SELECT * FROM P_PARAMETROS_ESPECIFICOS WHERE IDVARIEABLE='" + cbo_variable.EditValue.ToString() + "' AND IDPRESUPUESTO='" + cbo_presupuesto.EditValue.ToString() + "' AND IDESTADO='1'"); if (TB_VERIFICACION.Rows.Count > 0) { MessageBox.Show("Ya existe un registro para esta variable y este presupuesto !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string rpta = NFunciones.ExecuteSQL("INSERT INTO P_PARAMETROS_ESPECIFICOS(ID,IDVARIEABLE,IDESTADO,IDPRESUPUESTO,DESCRIPCION,SP_ASIGNADO)VALUES('" + txt_id.Text + "','" + cbo_variable.EditValue.ToString() + "','1','" + cbo_presupuesto.EditValue.ToString() + "','" + txt_descripcion.Text + "','" + txt_sp.Text + "')"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Guardado Correctamente"); } } if (_modo.Equals("E")) { string rpta = NFunciones.ExecuteSQL("UPDATE P_PARAMETROS_ESPECIFICOS SET DESCRIPCION='" + txt_descripcion.Text + "',SP_ASIGNADO='" + txt_sp.Text + "' WHERE ID='" + txt_id.Text + "'"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Actualizado Correctamente"); } } //----- insertar detalle string delete = NFunciones.ExecuteSQL("DELETE P_DPARAMETROS_ESPECIFICOS where ID = '" + txt_id.Text + "'"); if (vista_detalle.RowCount > 0) { for (int i = 0; i < vista_detalle.RowCount; i++) { string rpta = NFunciones.ExecuteSQL("IF NOT EXISTS (SELECT * FROM P_DPARAMETROS_ESPECIFICOS WHERE ID ='" + txt_id.Text + "' AND IDFUNDO='" + vista_detalle.GetRowCellValue(i, IDFUNDO).ToString() + "' AND IDCULTIVO='" + vista_detalle.GetRowCellValue(i, IDCULTIVO).ToString() + "') INSERT INTO P_DPARAMETROS_ESPECIFICOS (ID,IDFUNDO,IDCULTIVO,IDVARIEABLE,VALOR) VALUES('" + txt_id.Text + "','" + vista_detalle.GetRowCellValue(i, IDFUNDO).ToString() + "','" + vista_detalle.GetRowCellValue(i, IDCULTIVO).ToString() + "','" + cbo_variable.EditValue.ToString() + "','" + vista_detalle.GetRowCellValue(i, VALOR).ToString() + "')"); } } LlegarGrillaDetalle(txt_id.Text); _modo = ""; activartxt(false); }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { if (this.cbo_empresa.Text == "[Seleccionar..]") { MensajeError("Falta Seleccionar Empresa"); return; } string rpta = ""; if (this.txt_codigo.Text == string.Empty) { MensajeError("Falta Ingresar Codigo"); return; } if (this.txt_descripcion.Text == string.Empty) { MensajeError("Falta Ingresar Descripción"); return; } string codigo; DataTable dtid = new DataTable(); if (this.IsNuevo) { dtid = NFunciones.TABLADATOS("EXEC SP_IDFUNDO''"); codigo = dtid.Rows[0]["ID"].ToString(); txt_codigo.Text = codigo; rpta = NFunciones.ExecuteSQL("INSERT INTO P_FUNDO(IDEMPRESA,IDFUNDO,DESCRIPCION)VALUES('" + Convert.ToString(cbo_empresa.EditValue) + "','" + txt_codigo.Text + "','" + txt_descripcion.Text + "')"); } else { rpta = NFunciones.ExecuteSQL("UPDATE P_FUNDO SET IDEMPRESA='" + Convert.ToString(cbo_empresa.EditValue) + "',DESCRIPCION='" + txt_descripcion.Text + "' WHERE IDFUNDO='" + txt_codigo.Text + "'"); } if (rpta.Equals("Ok")) { if (this.IsNuevo) { this.MensajeOk("Se Inserto los Datos Correctamente"); } else { this.MensajeOk("Se Actualizo los Datos Correctamente"); } } else { this.MensajeError(rpta); } this.IsNuevo = false; this.IsEditar = false; this.Botones(); this.HabilitarTexbox(false); this.llenargrilla(); } catch (Exception ex) { MessageBox.Show(ex.Message + ex.StackTrace); } }
private void importacion() { //CheckForIllegalCrossThreadCalls = false; try { DataTable TablaNisira = new DataTable(); TablaNisira = NFunciones.TABLADATOSNISIRA("exec sp_executesql N'exec PERSONAL_NISRA_RG @P1 , @P2 , @P3 ',N'@P1 varchar(3),@P2 varchar(13),@P3 float','001','ADMINISTRADOR',0"); string I = ""; string errores = ""; totalregistros = TablaNisira.Rows.Count; foreach (DataRow row in TablaNisira.Rows) { DateTime fechanaci = Convert.ToDateTime((row["FNACIMIENTO"])); DateTime time = Convert.ToDateTime((row["FNACIMIENTO"])); // Use current time string format = "dd-MM-yyyy"; // MessageBox.Show(row["idcodigogeneral"].ToString().ToUpper().Trim() +"-"+ row["nombres"].ToString().ToUpper().Trim() + "-" + row["ap_paterno"].ToString().ToUpper().Trim() + "-" + row["ap_materno"].ToString().ToUpper().Trim() + "-" + row["nrodocumento"].ToString().ToUpper().Trim() + "-" + row["sexo"].ToString().ToUpper().Trim() + "-" + row["l_negra"].ToString().ToUpper().Trim() + "-" + row["PlanActual"].ToString().ToUpper().Trim() + "-" + row["cargo"].ToString().ToUpper().Trim()); I = NFunciones.ExecuteSQL("EXEC SP_INSERTARACTUALIZAR_PERSONALNISIRA'" + row["idcodigogeneral"].ToString().ToUpper().Trim() + "','" + row["nombres"].ToString().ToUpper().Trim() + "','" + row["a_paterno"].ToString().ToUpper().Trim() + "','" + row["a_materno"].ToString().ToUpper().Trim() + "','" + row["nrodocumento"].ToString().ToUpper().Trim() + "','" + row["sexo"].ToString().ToUpper().Trim() + "','" + row["l_negra"].ToString().ToUpper().Trim() + "','" + row["PlanActual"].ToString().ToUpper().Trim() + "','" + row["cargo"].ToString().ToUpper().Trim() + "','" + row["estado"].ToString().ToUpper().Trim() + "','" + row["afp_dsc"].ToString().ToUpper().Trim() + "','" + row["Asig_fam"].ToString().ToUpper().Trim() + "','" + row["dsc_planilla"].ToString().ToUpper().Trim() + "','" + row["IDUBIGEO"].ToString().ToUpper().Trim() + "','" + row["DIRECCION"].ToString().ToUpper().Trim() + "','" + row["CELULAR"].ToString().ToUpper().Trim() + "','" + row["EMAIL"].ToString().ToUpper().Trim() + "','SI'"); insertados++; totalregistros = totalregistros - 1; porcentajeImport = Convert.ToInt32((totalregistros / insertados) * 100); // sub_importar.ReportProgress(100 - Convert.ToInt32((insertados / total) * 100)); mensaje = "Actualizando Codigo : " + row["idcodigogeneral"].ToString().ToUpper().Trim() + " - Faltan : " + totalregistros + ""; if (!I.Equals("OK")) { errores = "No se puedo Insertar o Actualizar : " + row["idcodigogeneral"].ToString().ToUpper().Trim() + "\n"; } } if (!errores.Equals("")) { MessageBox.Show("Proceso Terminado Correctamente", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); this.Close(); } else { MessageBox.Show("Proceso Terminado Con errores", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); string ruta = "C:\\DATA"; string rutaCompleta = ruta + "\\errores.txt"; if (!Directory.Exists(ruta)) { Directory.CreateDirectory(ruta); } if (File.Exists(rutaCompleta)) { File.Delete(rutaCompleta); } using (StreamWriter file = new StreamWriter(rutaCompleta, true)) { file.WriteLine(errores); file.Close(); } } Program.estadosincronizacion = "S"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void Procesar() { if (tipo.Equals("L")) { try { string ext = Path.GetExtension(txt_ruta.Text); string hoja = "dpresupuesto_lote"; DataTable dtlote = new DataTable(); dtlote = VariablesGenerales.ImportarExcel(txt_ruta.Text, ext, hoja); if (dtlote.Rows.Count > 0) { if (dtlote.Columns.Count > 22 || dtlote.Columns.Count < 22) { MessageBox.Show(@"El archivo no es correcto , intente abrir el archivo correcto "); estado = "S"; } else { CONTADOR = 0; foreach (DataRow row in dtlote.Rows) { idempresa = row[0].ToString().Trim(); idpresupuesto = row[1].ToString().Trim(); idcultivo = row[2].ToString().Trim(); IdVariedad = row[3].ToString().Trim(); idetapa = row[4].ToString().Trim(); idestructura = row[5].ToString().Trim(); idtipocosto = row[6].ToString().Trim(); iditemcosto = row[7].ToString().Trim(); idactividadsubgru = row[8].ToString().Trim(); idlaborproducto = row[9].ToString().Trim(); idunidad = row[10].ToString().Trim(); con_igv = Convert.ToInt32(row[11].ToString()); periodo = row[12].ToString().Trim(); semana = row[13].ToString().Trim(); cantidad = Convert.ToDecimal(row[14].ToString()); costo = Convert.ToDecimal(row[15].ToString()); idmoneda = row[16].ToString().Trim(); dias_pago = Convert.ToInt32(row[17].ToString()); idobjetivo = row[18].ToString().Trim(); idsubitemcosto = row[19].ToString().Trim(); idfundo = row[20].ToString().Trim(); idlote = row[21].ToString().Trim(); CONTADOR++; string validar = ValidarxLote(idempresa, idpresupuesto, idcultivo, IdVariedad, idetapa, idestructura, idtipocosto, iditemcosto, idactividadsubgru, idlaborproducto, idunidad, con_igv, periodo, semana, cantidad, costo, idmoneda, dias_pago, idobjetivo, idsubitemcosto, idfundo, idlote, IDITEMCOSTO_US, IDCULTIVO_US); mensajeprogreso = "Validando Registro N° " + Convert.ToString(CONTADOR); if (!validar.Equals("Ok")) { mensaje = validar + " Registro N° " + CONTADOR; } } if (mensaje.Equals("")) { if (eliminarData.Equals("S")) { string pro = NFunciones.ExecuteSQL("DELETE P_DPRESUPUESTO_LOTE WHERE IdItemCosto='" + IDITEMCOSTO_US + "' AND IDCULTIVO='" + IDCULTIVO_US + "'"); mensajeprogreso = !pro.Equals("Ok") ? "No se ha Podido Eliminar la Data Anterior !!" : "Se elimino la Data anterior !!"; } CONTADOR = 0; foreach (DataRow row in dtlote.Rows) { idempresa = row[0].ToString().Trim(); idpresupuesto = row[1].ToString().Trim(); idcultivo = row[2].ToString().Trim(); IdVariedad = row[3].ToString().Trim(); idetapa = row[4].ToString().Trim(); idestructura = row[5].ToString().Trim(); idtipocosto = row[6].ToString().Trim(); iditemcosto = row[7].ToString().Trim(); idactividadsubgru = row[8].ToString().Trim(); idlaborproducto = row[9].ToString().Trim(); idunidad = row[10].ToString().Trim(); con_igv = Convert.ToInt32(row[11].ToString()); periodo = row[12].ToString().Trim(); semana = row[13].ToString().Trim(); cantidad = Convert.ToDecimal(row[14].ToString()); costo = Convert.ToDecimal(row[15].ToString()); idmoneda = row[16].ToString().Trim(); dias_pago = Convert.ToInt32(row[17].ToString()); idobjetivo = row[18].ToString().Trim(); idsubitemcosto = row[19].ToString().Trim(); idfundo = row[20].ToString().Trim(); idlote = row[21].ToString().Trim(); CONTADOR++; string rpta = NFunciones.ExecuteSQL("INSERT INTO P_DPRESUPUESTO_LOTE( IdEmpresa ,idPresupuesto ,IDCULTIVO ,IdVariedad , IdEtapa ," + "IdEstructura, IdTipoCosto, IdItemCosto, IdActividadSubGru, IdLaborProducto, IdUnidad, con_igv," + "Periodo, semana, Cantidad, Costo, IdMoneda, dias_pago, IDOBJETIVO, IdSubItemCosto, IDFUNDO, IdLote)" + "VALUES('" + idempresa + "','" + idpresupuesto + "','" + idcultivo + "','" + IdVariedad + "','" + idetapa + "','" + idestructura + "','" + idtipocosto + "','" + iditemcosto + "','" + idactividadsubgru + "','" + idlaborproducto + "','" + idunidad + "','" + con_igv + "','" + periodo + "','" + semana + "','" + cantidad + "','" + costo + "','" + idmoneda + "','" + dias_pago + "','" + idobjetivo + "','" + idsubitemcosto + "','" + idfundo + "','" + idlote + "')"); mensajeprogreso = "Insertando Registro N° " + Convert.ToString(CONTADOR); //MessageBox.Show(rpta); if (!rpta.Equals("Ok")) { errorinsert = errorinsert + " " + rpta + "Registro N° " + Convert.ToString(CONTADOR) + "\n"; } } } else { errorinsert = errorinsert + " " + mensaje + "\n"; } } if (errorinsert.Equals("")) { MessageBox.Show(@"Importando Correctamente"); } else { MessageBox.Show(@"ERRORES : " + "\n" + errorinsert); } // dataGridView1.DataSource = dtlote; } estado = "S"; } catch (Exception EX) { estado = "S"; MessageBox.Show(EX.Message); } } if (tipo.Equals("V")) { //try //{ string ext = Path.GetExtension(txt_ruta.Text); string hoja = "dpresupuesto_variedad"; DataTable dtlote = new DataTable(); dtlote = VariablesGenerales.ImportarExcel(txt_ruta.Text, ext, hoja); if (dtlote.Rows.Count > 0) { //string nrows = Convert.ToString(dtlote.Columns.Count); //MessageBox.Show(nrows); //if (nrows.Equals("21")) //{ // MessageBox.Show("El archivo no es correcto , intente abrir el archivo correcto "); // errorinsert = errorinsert + "El archivo no es el correcto"; // estado = "S"; //} //else //{ foreach (DataRow row in dtlote.Rows) { idempresa = row[0].ToString().Trim(); idpresupuesto = row[1].ToString().Trim(); idcultivo = row[2].ToString().Trim(); IdVariedad = row[3].ToString().Trim(); idetapa = row[4].ToString().Trim(); idestructura = row[5].ToString().Trim(); idtipocosto = row[6].ToString().Trim(); iditemcosto = row[7].ToString().Trim(); idactividadsubgru = row[8].ToString().Trim(); idlaborproducto = row[9].ToString().Trim(); idunidad = row[10].ToString().Trim(); con_igv = Convert.ToInt32(row[11].ToString()); periodo = row[12].ToString().Trim(); semana = row[13].ToString().Trim(); cantidad = Convert.ToDecimal(row[14].ToString()); costo = Convert.ToDecimal(row[15].ToString()); idmoneda = row[16].ToString().Trim(); dias_pago = Convert.ToInt32(row[17].ToString()); idobjetivo = row[18].ToString().Trim(); idsubitemcosto = row[19].ToString().Trim(); idfundo = row[20].ToString().Trim(); // idlote = row[21].ToString().Trim(); CONTADOR++; string validar = Validarxvariedad(idempresa, idpresupuesto, idcultivo, IdVariedad, idetapa, idestructura, idtipocosto, iditemcosto, idactividadsubgru, idlaborproducto, idunidad, con_igv, periodo, semana, cantidad, costo, idmoneda, dias_pago, idobjetivo, idsubitemcosto, idfundo, IDITEMCOSTO_US, IDCULTIVO_US); mensajeprogreso = "Validando Registro N° " + Convert.ToString(CONTADOR); if (!validar.Equals("Ok")) { mensaje = validar + " Registro N° " + CONTADOR; } } if (mensaje.Equals("")) { if (eliminarData.Equals("S")) { string pro = NFunciones.ExecuteSQL("DELETE P_DPRESUPUESTO_RG WHERE IdItemCosto='" + IDITEMCOSTO_US + "' AND IDCULTIVO='" + IDCULTIVO_US + "'"); if (!pro.Equals("Ok")) { mensajeprogreso = "No se ha Podido Eliminar la Data Anterior !!"; } else { mensajeprogreso = "Se elimino la Data anterior !!"; } } CONTADOR = 0; foreach (DataRow row in dtlote.Rows) { idempresa = row[0].ToString().Trim(); idpresupuesto = row[1].ToString().Trim(); idcultivo = row[2].ToString().Trim(); IdVariedad = row[3].ToString().Trim(); idetapa = row[4].ToString().Trim(); idestructura = row[5].ToString().Trim(); idtipocosto = row[6].ToString().Trim(); iditemcosto = row[7].ToString().Trim(); idactividadsubgru = row[8].ToString().Trim(); idlaborproducto = row[9].ToString().Trim(); idunidad = row[10].ToString().Trim(); con_igv = Convert.ToInt32(row[11].ToString()); periodo = row[12].ToString().Trim(); semana = row[13].ToString().Trim(); cantidad = Convert.ToDecimal(row[14].ToString()); costo = Convert.ToDecimal(row[15].ToString()); idmoneda = row[16].ToString().Trim(); dias_pago = Convert.ToInt32(row[17].ToString()); idobjetivo = row[18].ToString().Trim(); idsubitemcosto = row[19].ToString().Trim(); idfundo = row[20].ToString().Trim(); //idlote = row[21].ToString().Trim(); CONTADOR++; string rpta = NFunciones.ExecuteSQL("INSERT INTO P_DPRESUPUESTO_RG( IdEmpresa ,idPresupuesto ,IDCULTIVO ,IdVariedad , IdEtapa ," + "IdEstructura, IdTipoCosto, IdItemCosto, IdActividadSubGru, IdLaborProducto, IdUnidad, con_igv," + "Periodo, semana, Cantidad, Costo, IdMoneda, dias_pago, IDOBJETIVO, IdSubItemCosto, IDFUNDO)" + "VALUES('" + idempresa + "','" + idpresupuesto + "','" + idcultivo + "','" + IdVariedad + "','" + idetapa + "','" + idestructura + "','" + idtipocosto + "','" + iditemcosto + "','" + idactividadsubgru + "','" + idlaborproducto + "','" + idunidad + "','" + con_igv + "','" + periodo + "','" + semana + "','" + cantidad + "','" + costo + "','" + idmoneda + "','" + dias_pago + "','" + idobjetivo + "','" + idsubitemcosto + "','" + idfundo + "')"); mensajeprogreso = "Insertando Registro N° " + Convert.ToString(CONTADOR); if (!rpta.Equals("Ok")) { errorinsert = errorinsert + " " + rpta + "Registro N° " + Convert.ToString(CONTADOR) + "\n"; } } } else { errorinsert = errorinsert + " " + mensaje + "\n"; } if (errorinsert.Equals("")) { MessageBox.Show(@"Importando Correctamente"); } else { MessageBox.Show(@"ERRORES : " + "\n" + errorinsert); } // dataGridView1.DataSource = dtlote; } estado = "S"; //} //catch (Exception EX) //{ // estado = "S"; // MessageBox.Show(EX.Message); //} } }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (txt_codempresa.Text.Equals("")) { MessageBox.Show("Debe Ingresar Codigo de Empresa !"); return; } if (txt_razonsocial.Text.Equals("")) { MessageBox.Show("Debe Ingresar Razon Social !"); return; } if (txt_ruc.Text.Equals("")) { MessageBox.Show("Debe Ingresar Ruc!"); return; } if (txt_direccion.Text.Equals("")) { MessageBox.Show("Debe Ingresar Dirección !"); return; } if (txt_razonsocial.Text.Equals("")) { MessageBox.Show("Debe Ingresar Razon Social !"); return; } if (txt_tcambio.Text.Equals("")) { MessageBox.Show("Debe Ingresar Tipo de Cambio !"); return; } if (txt_codigoaduanas.Text.Equals("")) { MessageBox.Show("Debe Ingresar Codigo Aduanas !"); return; } if (txt_regimen.Text.Equals("")) { MessageBox.Show("Debe Ingresar Codigo de Regimen !"); return; } if (_modo.Equals("N")) { DataTable tb_table = new DataTable(); tb_table = NFunciones.TABLASQL("select idempresa from tb_empresa where idempresa='" + txt_codempresa.Text + "'"); if (tb_table.Rows.Count > 0) { MessageBox.Show("Ya existe el codigo ingresado debe colocar uno que nuevo !"); return; } string rpta = NFunciones.ExecuteSQL("insert into tb_empresa (idempresa,razonsocial,direccion,telef,email,ruc,TC,codigo_aduanas,regimen,porc_drawback) values('" + txt_codempresa.Text.ToUpper() + "','" + txt_razonsocial.Text.ToUpper() + "','" + txt_direccion.Text.ToUpper() + "','" + txt_telefono.Text.ToUpper() + "','" + txt_email.Text.ToUpper() + "','" + txt_ruc.Text.ToUpper() + "','" + txt_tcambio.Text.ToUpper() + "','" + txt_codigoaduanas.Text.ToUpper() + "','" + txt_regimen.Text.ToUpper() + "','" + txt_porc_drawback.Text + "')"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Guardado Correctamente"); } } if (_modo.Equals("E")) { string rpta = NFunciones.ExecuteSQL("UPDATE tb_empresa SET razonsocial='" + txt_razonsocial.Text.ToUpper() + "',direccion='" + txt_direccion.Text.ToUpper() + "',telef='" + txt_telefono.Text.ToUpper() + "',email='" + txt_email.Text.ToUpper() + "',ruc='" + txt_ruc.Text.ToUpper() + "',TC='" + txt_tcambio.Text + "',codigo_aduanas='" + txt_codigoaduanas.Text + "', regimen='" + txt_regimen.Text + "',porc_drawback='" + txt_porc_drawback.Text + "' WHERE idempresa='" + txt_codempresa.Text + "'"); if (rpta.Equals("Ok")) { LlegarGrilla(); botones(true); activartxt(false); MessageBox.Show("Actualizado Correctamente"); } } }
private void btn_txt_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { try { string texto = Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_DOCUMENTO)) + ".txt"; string ruta = "c:\\DATA"; string rutaCompleta = ruta + "\\" + texto; if (!Directory.Exists(ruta)) { Directory.CreateDirectory(ruta); } if (File.Exists(rutaCompleta)) { File.Delete(rutaCompleta); } DataTable tb_cabecera = NFunciones.TABLASQL("SELECT 0 INDICADOR,E.codigo_aduanas ADUANA,YEAR(D.fecha)ANOP,D.ndua DUA,D.regimen REGIMEN,1 SERIE,D.importerecuperacion FOB,'N' PRODUCCION FROM tb_dua D INNER JOIN tb_empresa E ON D.idempresa=E.idempresa INNER JOIN tb_cobrarpagardoc C ON C.idempresa=E.idempresa AND C.idcobrarpagardoc=D.idcobrarpagardoc WHERE D.idempresa='001' AND D.IDDUA='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "'"); DataTable tb_exportacion = NFunciones.TABLASQL("SELECT 1 INDICADOR,'00' FACTURA,C.ruc RUC,T.serie SERIE,T.numero NUMERO,SUBSTRING(CONVERT(NVARCHAR(8),T.fecha,112),7,2)+SUBSTRING(CONVERT(NVARCHAR(8),T.fecha,112),5,2)+SUBSTRING(CONVERT(NVARCHAR(8),T.fecha,112),1,4) FECHA, RIGHT('000' + Ltrim(Rtrim(D.item)),3) ITEM,D.cantidad CANT,D.cantidad CANT_SERIE,D.idunidad MEDIDA,D.descripcion MERCADERIA FROM tb_cobrarpagardoc T INNER JOIN tb_clieprov C ON C.idempresa=T.idempresa AND T.idclieprov=C.idclieprov INNER JOIN tb_dcobrarpagardoc D ON D.idcobrarpagardoc=T.idcobrarpagardoc AND D.idempresa=T.idempresa WHERE T.idcobrarpagardoc IN (SELECT idorigen FROM tb_docreferencia WHERE iddestino='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "' AND idempresa='" + VariablesGenerales.Empresa + "')"); DataTable tb_insumos = NFunciones.TABLASQL("EXEC SP_DETALLE_DAM'" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "'"); if (tb_cabecera.Rows.Count == 1) { string cabecera = tb_cabecera.Rows[0]["INDICADOR"].ToString() + "|"; cabecera = cabecera + tb_cabecera.Rows[0]["ADUANA"].ToString() + "|"; cabecera = cabecera + tb_cabecera.Rows[0]["ANOP"].ToString() + "|"; cabecera = cabecera + tb_cabecera.Rows[0]["DUA"].ToString() + "|"; cabecera = cabecera + tb_cabecera.Rows[0]["REGIMEN"].ToString() + "|"; cabecera = cabecera + tb_cabecera.Rows[0]["SERIE"].ToString() + "|"; cabecera = cabecera + tb_cabecera.Rows[0]["FOB"].ToString() + "|"; cabecera = cabecera + tb_cabecera.Rows[0]["PRODUCCION"].ToString(); using (StreamWriter file = new StreamWriter(rutaCompleta, true)) { file.WriteLine(cabecera); //se agrega información al documento foreach (DataRow row in tb_exportacion.Rows) { string exportacion = row["INDICADOR"].ToString().ToUpper().Trim() + "|" + row["FACTURA"].ToString().ToUpper().Trim() + "|" + row["RUC"].ToString().ToUpper().Trim() + "|" + row["SERIE"].ToString().ToUpper().Trim() + "|" + row["NUMERO"].ToString().ToUpper().Trim() + "|" + row["FECHA"].ToString().ToUpper().Trim() + "|" + row["ITEM"].ToString().ToUpper().Trim() + "|" + row["CANT"].ToString().ToUpper().Trim() + "|" + row["CANT_SERIE"].ToString().ToUpper().Trim() + "|" + row["MEDIDA"].ToString().ToUpper().Trim() + "|" + row["MERCADERIA"].ToString().ToUpper().Trim(); file.WriteLine(exportacion); //se agrega información al documento } foreach (DataRow row in tb_insumos.Rows) { string exportacion = row["INDICADOR"].ToString().ToUpper().Trim() + "|" + row["MODALIDAD"].ToString().ToUpper().Trim() + "|" + row["RUC"].ToString().ToUpper().Trim() + "|" + row["SERIEDOC"].ToString().ToUpper().Trim() + "|" + row["NUMERODOC"].ToString().ToUpper().Trim() + "|" + row["FECHADOC"].ToString().ToUpper().Trim() + "|" + row["ITEM"].ToString().ToUpper().Trim() + "|" + row["CANTIDADTOTAL"].ToString().ToUpper().Trim() + "|" + row["CANTIDAEXPORTABLE"].ToString().ToUpper().Trim() + "|" + row["UNIDADMEDIDA"].ToString().ToUpper().Trim() + "|" + row["DESCRIPCIONMERCADERIA"].ToString().ToUpper().Trim() + "|" + "|" + "|" + "|" + row["DESCRIPCIONMERCADERIA"].ToString().ToUpper().Trim() + "|" + row["ADUANA"].ToString().ToUpper().Trim() + "|" + row["ANOEXPOR"].ToString().ToUpper().Trim() + "|" + row["DAM"].ToString().ToUpper().Trim() + "|" + row["REGIMEN"].ToString().ToUpper().Trim() + "|" + row["SERIE"].ToString().ToUpper().Trim(); file.WriteLine(exportacion); //se agrega información al documento } file.Close(); string afirmatxt = NFunciones.ExecuteSQL("update tb_dua set TXT='1' where iddua='" + Convert.ToString(vista_datos.GetFocusedRowCellValue(COL_ID)) + "' and idempresa='" + VariablesGenerales.Empresa + "'"); LlegarGrilla(); DialogResult Result = MessageBox.Show("El archivo se Guardo Correctamente en :" + rutaCompleta + "\n" + "Desea Abrirlo ?", "Información", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (Result == DialogResult.Yes) { ProcessStartInfo psi = new ProcessStartInfo("notepad.exe", rutaCompleta); Process p = Process.Start(psi); } } } } catch { MessageBox.Show("Elija un registro ", "Información", MessageBoxButtons.OK, MessageBoxIcon.Information); return; } }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { // validar que todos los campos esten llenos if (txt_id.Text.Equals("")) { MessageBox.Show("Debe Ingresar ID", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cbo_moneda.Text.Equals("[Seleccione]") || cbo_moneda.Text.Equals("")) { MessageBox.Show("Debe Ingresar Moneda", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_tc.Text.Equals("")) { MessageBox.Show("Debe Ingresar Tipo de Cambio", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cbo_clieprov.Text.Equals("[Seleccione]") || cbo_clieprov.Text.Equals("")) { MessageBox.Show("Debe Ingresar Proveedor", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cbo_clieprov.EditValue.Equals("")) { MessageBox.Show("Debe Ingresar Proveedor", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (dtp_fechadoc.Text.Equals("")) { MessageBox.Show("Debe Ingresar Fecha Documento", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cbo_documento.Text.Equals("[Seleccione]") || cbo_documento.Text.Equals("")) { MessageBox.Show("Debe Ingresar Documento", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_serie.Text.Equals("")) { MessageBox.Show("Debe Ingresar Serie", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_numero.Text.Equals("")) { MessageBox.Show("Debe Ingresar Numero", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_idoperacion.Text.Equals("C")) { if (cbo_puerto.Text.Equals("[Seleccione]") || cbo_puerto.Text.Equals("")) { MessageBox.Show("Debe Ingresar Puerto", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (cbo_regimen.Text.Equals("[Seleccione]") || cbo_regimen.Text.Equals("")) { MessageBox.Show("Debe Ingresar Regimen", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_dam.Text.Equals("")) { MessageBox.Show("Debe Ingresar DAM", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (string.IsNullOrEmpty(txt_anoimportacion.Text) || txt_anoimportacion.Text.Length != 4) { MessageBox.Show("Debe Ingresar Año Importación (AAAA)", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } if (vista_datos.RowCount < 1) { MessageBox.Show("Debe ingresar detalle !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { //vista_datos.SetFocusedRowCellValue(COL_ITEM, 1); //for (int i = 0; i < vista_datos.RowCount-1; i++) //{ // vista_datos.SetRowCellValue(i,"ITEM",i); //} for (int i = 0; i < vista_datos.RowCount; i++) { if (vista_datos.GetRowCellValue(i, COL_ITEM).ToString().Equals("") || Convert.ToDouble(vista_datos.GetRowCellValue(i, COL_ITEM)) <= 0) { MessageBox.Show("Debe ingresar Item !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_datos.GetRowCellValue(i, COL_IDPRODUCTO).ToString().Equals("") || vista_datos.GetRowCellValue(i, COL_IDPRODUCTO).ToString().Equals("[Seleccionar]")) { MessageBox.Show("Debe ingresar Codigo de Producto !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_datos.GetRowCellValue(i, COL_PRODUCTO).ToString().Equals("")) { MessageBox.Show("Debe ingresar Producto !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_datos.GetRowCellValue(i, COL_CANTIDAD).ToString().Equals("") || Convert.ToDouble(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) <= 0) { MessageBox.Show("Debe ingresar Cantidad !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_datos.GetRowCellValue(i, COL_PRECIOUNIT).ToString().Equals("") || Convert.ToDouble(vista_datos.GetRowCellValue(i, COL_PRECIOUNIT)) <= 0) { MessageBox.Show("Debe ingresar Precio Unitario !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (Convert.ToDouble(vista_datos.GetRowCellValue(i, COL_IMP)) <= 0) { vista_datos.SetFocusedRowCellValue(COL_IMP, 0); } } } //--------validado if (txt_serie.Text.Length < 4) { txt_serie.Text = txt_serie.Text.PadLeft(4, '0'); } if (txt_numero.Text.Length < 7) { txt_numero.Text = txt_numero.Text.PadLeft(7, '0'); } if (_opcion.Equals("N")) { DataTable tbvalidador = NFunciones.TABLASQL("SELECT * FROM tb_cobrarpagardoc WHERE idempresa='" + VariablesGenerales.Empresa + "' AND iddocumento='" + cbo_documento.EditValue.ToString() + "' AND serie='" + txt_serie.Text + "' AND numero='" + txt_numero.Text + "' AND idclieprov='" + cbo_clieprov.EditValue.ToString() + "'and tipo='" + txt_idoperacion.Text + "'"); if (tbvalidador.Rows.Count > 0) { MessageBox.Show("Ya existe el documento , intente con otro!", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string mensaje = ""; string cabecera = ""; if (txt_idoperacion.Text.Equals("C")) { cabecera = NFunciones.ExecuteSQL("insert into tb_cobrarpagardoc(idcobrarpagardoc,idempresa,iddocumento,serie,numero,idclieprov,razonsocial,estado,tipo,idmoneda,TC,fecha,idregimenimportacion,idpuertoimportacion,dam,anoimportacion)values('" + txt_id.Text + "','" + VariablesGenerales.Empresa + "','" + cbo_documento.EditValue.ToString() + "','" + txt_serie.Text + "','" + txt_numero.Text + "','" + cbo_clieprov.EditValue.ToString() + "','" + cbo_clieprov.Text.ToUpper() + "','1','" + txt_idoperacion.Text + "','" + cbo_moneda.EditValue.ToString() + "','" + txt_tc.Text + "',Convert(DATE,'" + dtp_fechadoc.Text + "',103),'" + cbo_regimen.EditValue.ToString() + "','" + cbo_puerto.EditValue.ToString() + "','" + txt_dam.Text + "','" + txt_anoimportacion.Text + "')"); } if (txt_idoperacion.Text.Equals("V")) { cabecera = NFunciones.ExecuteSQL("insert into tb_cobrarpagardoc(idcobrarpagardoc,idempresa,iddocumento,serie,numero,idclieprov,razonsocial,estado,tipo,idmoneda,TC,fecha)values('" + txt_id.Text + "','" + VariablesGenerales.Empresa + "','" + cbo_documento.EditValue.ToString() + "','" + txt_serie.Text + "','" + txt_numero.Text + "','" + cbo_clieprov.EditValue.ToString() + "','" + cbo_clieprov.Text.ToUpper() + "','1','" + txt_idoperacion.Text + "','" + cbo_moneda.EditValue.ToString() + "','" + txt_tc.Text + "',Convert(DATE,'" + dtp_fechadoc.Text + "',103))"); } if (cabecera.Equals("Ok")) { for (int i = 0; i < vista_datos.RowCount; i++) { //int item = i + 1; string detalle = NFunciones.ExecuteSQL("insert into tb_dcobrarpagardoc (idempresa,idcobrarpagardoc,item,idproducto,descripcion,idunidad,cantidad,porc_imp,imp,preciounit,preciototal,idmoneda,TC) values('" + VariablesGenerales.Empresa + "','" + txt_id.Text + "','" + vista_datos.GetRowCellValue(i, COL_ITEM).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_IDPRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_PRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_MEDIDA).ToString() + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_IMP)) + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_IMPUESTO)) + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_PRECIOUNIT)) + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_TOTAL)) + "','" + cbo_moneda.EditValue.ToString() + "','" + txt_tc.Text + "')"); if (txt_idoperacion.Text.Equals("C")) { string mov = NFunciones.ExecuteSQL("insert into tb_movcobrarpagardoc_drakback (idempresa,idtransaccion,idcobrarpagardoc,idproducto,descripcion,idunidad,cantidad,factor,cantidadorigen,item) values('" + VariablesGenerales.Empresa + "','" + txt_id.Text + "','" + txt_id.Text + "','" + vista_datos.GetRowCellValue(i, COL_IDPRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_PRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_MEDIDA).ToString() + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) + "','1','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) + "','" + vista_datos.GetRowCellValue(i, COL_ITEM).ToString() + "')"); } if (txt_idoperacion.Text.Equals("V")) { string mov = NFunciones.ExecuteSQL("insert into tb_movcobrarpagardoc_drakback (idempresa,idtransaccion,idcobrarpagardoc,idproducto,descripcion,idunidad,cantidad,factor,cantidadorigen,item) values('" + VariablesGenerales.Empresa + "','" + txt_id.Text + "','" + txt_id.Text + "','" + vista_datos.GetRowCellValue(i, COL_IDPRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_PRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_MEDIDA).ToString() + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) + "','-1','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) + "','" + vista_datos.GetRowCellValue(i, COL_ITEM).ToString() + "')"); } } MessageBox.Show("Guardado Correctamente"); botones(true); LlegarGrilla(); activartxt(false); if (txt_idoperacion.Text.Equals("C")) { VariablesGenerales.refrescompras = "S"; } if (txt_idoperacion.Text.Equals("V")) { VariablesGenerales.refresventas = "S"; } } else { MessageBox.Show("Error al Guardar"); return; } } //-------------actualizar if (_opcion.Equals("E")) { string rpta = NFunciones.ExecuteSQL("update tb_cobrarpagardoc set iddocumento='" + cbo_documento.EditValue.ToString() + "',serie='" + txt_serie.Text + "',numero='" + txt_numero.Text + "', idclieprov='" + cbo_clieprov.EditValue.ToString() + "',razonsocial='" + cbo_clieprov.Text.ToString() + "',idmoneda='" + cbo_moneda.EditValue.ToString() + "',TC='" + txt_tc.Text + "',fecha = Convert(DATE,'" + dtp_fechadoc.Text + "',103) ,idregimenimportacion='" + cbo_regimen.EditValue.ToString() + "',idpuertoimportacion='" + cbo_puerto.EditValue.ToString() + "',dam='" + txt_dam.Text + "',anoimportacion='" + txt_anoimportacion.Text + "' where idcobrarpagardoc='" + txt_id.Text + "' and idempresa='" + VariablesGenerales.Empresa + "'"); string del = NFunciones.ExecuteSQL("delete tb_dcobrarpagardoc where idempresa='" + VariablesGenerales.Empresa + "' and idcobrarpagardoc='" + txt_id.Text + "'"); string delmov = NFunciones.ExecuteSQL("delete tb_movcobrarpagardoc_drakback where idempresa='" + VariablesGenerales.Empresa + "' and idcobrarpagardoc='" + txt_id.Text + "' and idtransaccion='" + txt_id.Text + "'"); if (rpta.Equals("Ok")) { //---agregar for (int i = 0; i < vista_datos.RowCount; i++) { //int item = i + 1; string detalle = NFunciones.ExecuteSQL("insert into tb_dcobrarpagardoc (idempresa,idcobrarpagardoc,item,idproducto,descripcion,idunidad,cantidad,porc_imp,imp,preciounit,preciototal,idmoneda,TC) values('" + VariablesGenerales.Empresa + "','" + txt_id.Text + "','" + vista_datos.GetRowCellValue(i, COL_ITEM).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_IDPRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_PRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_MEDIDA).ToString() + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_IMP)) + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_IMPUESTO)) + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_PRECIOUNIT)) + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_TOTAL)) + "','" + cbo_moneda.EditValue.ToString() + "','" + txt_tc.Text + "')"); if (txt_idoperacion.Text.Equals("C")) { string mov = NFunciones.ExecuteSQL("insert into tb_movcobrarpagardoc_drakback (idempresa,idtransaccion,idcobrarpagardoc,idproducto,descripcion,idunidad,cantidad,factor,item) values('" + VariablesGenerales.Empresa + "','" + txt_id.Text + "','" + txt_id.Text + "','" + vista_datos.GetRowCellValue(i, COL_IDPRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_PRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_MEDIDA).ToString() + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) + "','1','" + vista_datos.GetRowCellValue(i, COL_ITEM).ToString() + "')"); } if (txt_idoperacion.Text.Equals("V")) { string mov = NFunciones.ExecuteSQL("insert into tb_movcobrarpagardoc_drakback (idempresa,idtransaccion,idcobrarpagardoc,idproducto,descripcion,idunidad,cantidad,factor,item) values('" + VariablesGenerales.Empresa + "','" + txt_id.Text + "','" + txt_id.Text + "','" + vista_datos.GetRowCellValue(i, COL_IDPRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_PRODUCTO).ToString() + "','" + vista_datos.GetRowCellValue(i, COL_MEDIDA).ToString() + "','" + Convert.ToDecimal(vista_datos.GetRowCellValue(i, COL_CANTIDAD)) + "','-1','" + vista_datos.GetRowCellValue(i, COL_ITEM).ToString() + "')"); } } LlegarGrilla(); MessageBox.Show("Actualizado Correctamente"); botones(true); LlegarGrilla(); activartxt(false); VariablesGenerales.refrescompras = "S"; } else { MessageBox.Show("Error al Actualizar"); return; } } _opcion = ""; }
private void btn_guardar_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { if (txt_dua.Text.Equals("")) { MessageBox.Show("Debe ingresar el Numero de DUA !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_tc.Text.Equals("")) { MessageBox.Show("Debe ingresar Tipo de Cambio !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_regimen.Text.Equals("")) { MessageBox.Show("Debe ingresar Codigo de Regimen !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_aduanas.Text.Equals("")) { MessageBox.Show("Debe ingresar Codigo Aduanas !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (txt_porc_drawback.Text.Equals("")) { MessageBox.Show("Debe ingresar Porcentaje DrawBack !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_insumos.RowCount <= 0) { MessageBox.Show("Debe Agregar Insumos !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (vista_exportaciones.RowCount <= 0) { MessageBox.Show("Debe Agregar Exportación !", "Alerta", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (tipo.Equals("N")) { string cabecera = NFunciones.ExecuteSQL("insert into tb_dua(idempresa,iddua,ndua,tc,codigo_aduanas,porc_drawback,importerecuperacion,importetotal,regimen,fecha,idcobrarpagardoc,ncajas) values('" + VariablesGenerales.Empresa + "','" + txt_iddua.Text + "','" + txt_dua.Text + "','" + txt_tc.Text + "','" + txt_aduanas.Text + "','" + txt_porc_drawback.Text + "','" + txt_totaldrawback.Text + "','" + txt_importetotal.Text + "','" + txt_regimen.Text + "',Convert(DATE,'" + dtp_fechaoperacion.Text + "',103),'" + cbo_exportaciones.EditValue.ToString() + "','" + txt_ncajas.Text + "') "); string referencia = NFunciones.ExecuteSQL("insert into tb_docreferencia (idempresa,idorigen,iddestino) values ('" + VariablesGenerales.Empresa + "','" + cbo_exportaciones.EditValue.ToString() + "','" + txt_iddua.Text + "')"); if (cabecera.Equals("Ok")) { // insertar exportacion string exportacion = NFunciones.ExecuteSQL("update tb_dcobrarpagardoc set idref='" + txt_iddua.Text + "' where idcobrarpagardoc='" + cbo_exportaciones.EditValue.ToString() + "'"); //insertar insumos for (int i = 0; i < vista_insumos.RowCount; i++) { string insumos = NFunciones.ExecuteSQL(" insert into tb_movcobrarpagardoc_drakback(idempresa,idtransaccion,idproducto,descripcion,cantidad,factor,idcobrarpagardoc,idunidad,item)values('" + VariablesGenerales.Empresa + "','" + txt_iddua.Text + "','" + vista_insumos.GetRowCellValue(i, COL_IDPRODUCTOIN).ToString() + "','" + vista_insumos.GetRowCellValue(i, COL_PRODUCTOIN).ToString() + "','" + vista_insumos.GetRowCellValue(i, COL_CANTIDAD).ToString() + "','-1','" + vista_insumos.GetRowCellValue(i, COL_IDIN).ToString() + "','" + vista_insumos.GetRowCellValue(i, COL_UNIDADIN).ToString() + "','" + vista_insumos.GetRowCellValue(i, COL_ITEM).ToString() + "')"); } MessageBox.Show("Guardado Correctamnete !"); txt_dua.ReadOnly = true; txt_tc.ReadOnly = true; dtp_fechaoperacion.ReadOnly = true; Program.detalleinsumos = null; botones(false); VariablesGenerales.refduas = "S"; } } if (tipo.Equals("E")) { string cabecera = NFunciones.ExecuteSQL("update tb_dua set ndua='" + txt_dua.Text + "',tc='" + txt_tc.Text + "',codigo_aduanas='" + txt_aduanas.Text + "',porc_drawback='" + txt_porc_drawback.Text + "',fecha=convert(date,'" + dtp_fechaoperacion.Text + "',103),importerecuperacion='" + txt_totaldrawback.Text + "',importetotal='" + txt_importetotal.Text + "','" + txt_regimen.Text + "' ,idcobrarpagardoc='" + cbo_exportaciones.EditValue.ToString() + "',ncajas='" + txt_ncajas.Text + "' where iddua='" + txt_iddua.Text + "' and idempresa='" + VariablesGenerales.Empresa + "') "); string referencia = NFunciones.ExecuteSQL("update tb_docreferencia set idorigen='" + cbo_exportaciones.EditValue.ToString() + "' where idempresa='" + VariablesGenerales.Empresa + "' and iddestino='" + txt_iddua.Text + "'"); { // insertar exportacion string exportacion = NFunciones.ExecuteSQL("update tb_dcobrarpagardoc set idref='" + txt_iddua.Text + "' where idcobrarpagardoc='" + cbo_exportaciones.EditValue.ToString() + "'"); //insertar insumos string deleteinsumos = NFunciones.ExecuteSQL("delete tb_movcobrarpagardoc_drakback where idtransaccion='" + txt_iddua.Text + "' and idempresa='" + VariablesGenerales.Empresa + "'"); for (int i = 0; i < vista_insumos.RowCount; i++) { string insumos = NFunciones.ExecuteSQL("insert into tb_movcobrarpagardoc_drakback(idempresa,idtransaccion,idproducto,descripcion,cantidad,factor,idcobrarpagardoc,idunidad,item)values('" + VariablesGenerales.Empresa + "','" + txt_iddua.Text + "','" + vista_insumos.GetRowCellValue(i, COL_IDPRODUCTOIN).ToString() + "','" + vista_insumos.GetRowCellValue(i, COL_PRODUCTOIN).ToString() + "','" + vista_insumos.GetRowCellValue(i, COL_CANTIDAD).ToString() + "','-1','" + vista_insumos.GetRowCellValue(i, COL_IDIN).ToString() + "','" + vista_insumos.GetRowCellValue(i, COL_UNIDADIN).ToString() + "','" + vista_insumos.GetRowCellValue(i, COL_ITEM).ToString() + "')"); } Program.detalleinsumos = null; MessageBox.Show("Actualizado Correctamente !"); txt_dua.ReadOnly = true; txt_tc.ReadOnly = true; dtp_fechaoperacion.ReadOnly = true; botones(false); VariablesGenerales.refduas = "S"; } } }