private void Frm_Planilla_GenEventosPermiso_Activated(object sender, EventArgs e) { if (Sw_LOad) { //cmbtipo.ValueMember = "cele"; //cmbtipo.DisplayMember = "dele"; //cmbtipo.DataSource = ocapa.CaeSoft_GetAllTipoEventoPermiso; tb_plla_geneventospermisoBL BL = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BE = new tb_plla_geneventospermiso(); cmbtipo.ValueMember = "cele"; cmbtipo.DisplayMember = "descripcion"; cmbtipo.DataSource = BL.GetAllTipoEvento(VariablesPublicas.EmpresaID, BE).Tables[0]; U_RefrescaControles(); CargaDatos(); U_RefrescaControles(); Sw_LOad = false; } }
private void CargaDatos() { int nposcolumnasortear = 0; SortOrder PrvSotOrder = default(SortOrder); bool zordenado = false; string xcodcliente = ".."; string xpalabra1 = ""; string xpalabra2 = ""; string xpalabra3 = ""; if (txtfiltronombre.Text.Trim().Length > 0) { xpalabra1 = VariablesPublicas.Palabras(txtfiltronombre.Text, 1); xpalabra2 = VariablesPublicas.Palabras(txtfiltronombre.Text, 2); xpalabra3 = VariablesPublicas.Palabras(txtfiltronombre.Text, 3); } if ((Examinar.CurrentRow != null)) { xcodcliente = Examinar.Rows[Examinar.CurrentRow.Index].Cells["eventoperid"].Value.ToString(); } if ((Examinar.SortedColumn != null)) { nposcolumnasortear = Examinar.SortedColumn.Index; PrvSotOrder = Examinar.SortOrder; zordenado = true; } tb_plla_geneventospermisoBL BL = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BE = new tb_plla_geneventospermiso(); BE.norden = 1; BE.nomlike1 = xpalabra1; BE.nomlike2 = xpalabra2; BE.nomlike3 = xpalabra3; tablaclientes = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (BL.Sql_Error.Length > 0) { Frm_Class.ShowError(BL.Sql_Error, this); return; } Examinar.AutoGenerateColumns = false; Examinar.DataSource = tablaclientes; //if (!(txtdescripcion.MaxLength == tablaclientes.Columns["eventopername"].MaxLength)) //{ // txtdescripcion.MaxLength = tablaclientes.Columns["eventopername"].MaxLength; //} VariablesPublicas.PintaEncabezados(Examinar); if (zordenado) { if (PrvSotOrder == SortOrder.Ascending) { Examinar.Sort(Examinar.Columns[nposcolumnasortear], System.ComponentModel.ListSortDirection.Ascending); } else { Examinar.Sort(Examinar.Columns[nposcolumnasortear], System.ComponentModel.ListSortDirection.Descending); } } else { Examinar.Sort(Examinar.Columns["eventoperid"], System.ComponentModel.ListSortDirection.Ascending); } if (Examinar.CurrentRow == null) { if (Examinar.RowCount > 0) { Examinar.CurrentCell = Examinar.Rows[0].Cells["eventoperid"]; } } for (lc_cont = 0; lc_cont <= Examinar.Rows.Count - 1; lc_cont++) { if (Examinar.Rows[lc_cont].Cells["eventoperid"].Value.ToString() == xcodcliente) { Examinar.CurrentCell = Examinar.Rows[lc_cont].Cells["eventoperid"]; break; } } }
private void btnnuevo_Click(object sender, EventArgs e) { if (!(TabControl1.SelectedIndex == 0)) { TabControl1.SelectedIndex = 0; } u_n_opsel = 1; Blanquear(); U_RefrescaControles(); TabControl1.SelectedIndex = 0; TabControl1.SelectedIndex = 1; tb_plla_geneventospermisoBL BL = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BE = new tb_plla_geneventospermiso(); txtcodigo.Text = BL.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString(); chkactivo.Checked = true; cmbtipo.SelectedValue = "N"; txtdescripcion.Focus(); }
private void btngrabar_Click(object sender, EventArgs e) { if (U_Validacion()) { tb_plla_geneventospermisoBL BL = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BE = new tb_plla_geneventospermiso(); BE.eventoperid = txtcodigo.Text.Trim(); BE.norden = 1; tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (u_n_opsel == 1) { while (1 == 1) { tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (BL.Sql_Error.Length > 0) { Frm_Class.ShowError(BL.Sql_Error + "\r" + "Error al buscar código", this); return; } if (tmpcursor.Rows.Count > 0) { tb_plla_geneventospermisoBL BLMX = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BEMX = new tb_plla_geneventospermiso(); txtcodigo.Text = BLMX.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BEMX).Tables[0].Rows[0]["maximo_codigo"].ToString(); } else { break; } } tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; tmpcursor.Rows.Add(VariablesPublicas.InsertIntoTable(tmpcursor)); tmpcursor.Rows[0]["eventoperid"] = txtcodigo.Text.Trim(); } tmpcursor.Rows[0]["eventopername"] = txtdescripcion.Text.Trim(); tmpcursor.Rows[0]["planilla"] = 1; tmpcursor.Rows[0]["status"] = (chkactivo.Checked ? 1 : 0); tmpcursor.Rows[0]["rtpssunat"] = cmbcodsunat.SelectedValue; if (cmbtipo.SelectedValue != null) { tmpcursor.Rows[0]["tipoevento"] = cmbtipo.SelectedValue; } tmpcursor.AcceptChanges(); if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor)) { seguridadlog(); U_CancelarEdicion(0); } else { Frm_Class.ShowError(BL.Sql_Error, this); } } }
private void btneliminar_Click(object sender, EventArgs e) { if ((Examinar.CurrentRow != null)) { xnomcampo = ""; tb_plla_geneventospermisoBL BLEP = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BEEP = new tb_plla_geneventospermiso(); BEEP.eventoperid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["eventoperid"].Value.ToString(); //tmpcursor = BLEP.GetAll_CONSULTAIR(VariablesPublicas.EmpresaID, BEEP).Tables[0]; //tmpcursor = ocapa.IR_EVENTOSPERMISO(GlobalVars.GetInstance.Company, Examinar.Rows(Examinar.CurrentRow.Index).Cells("eventoperid").Value); if (BLEP.Sql_Error.Length > 0) { xnomcampo = BLEP.Sql_Error; Frm_Class.ShowError(BLEP.Sql_Error, this); } else { //if (tmpcursor.Rows.Count == 0) //{ //} //else //{ // for (lc_cont = 0; lc_cont <= tmpcursor.Rows.Count - 1; lc_cont++) // { // xnomcampo = xnomcampo + tmpcursor.Rows[lc_cont]["relacion"] + "\r"; // if (lc_cont + 1 == 10) // { // break; // } // } //} } if (xnomcampo.Length == 0) { tb_plla_geneventospermisoBL BL = new tb_plla_geneventospermisoBL(); tb_plla_geneventospermiso BE = new tb_plla_geneventospermiso(); BE.eventoperid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["eventoperid"].Value.ToString().Trim(); BE.norden = 1; tmptabla = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (BL.Sql_Error.Length == 0) { string message = "Desea eliminar datos " + tmptabla.Rows[0]["eventoperid"].ToString().Trim() + "-" + tmptabla.Rows[0]["eventopername"].ToString().Trim() + " ...?"; string caption = "Mensaje del Sistema"; MessageBoxButtons buttons = MessageBoxButtons.YesNo; DialogResult result; // Muestra el cuadro de mensaje. result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { BL.Eliminar(VariablesPublicas.EmpresaID, tmptabla); if (BL.Sql_Error.Length == 0) { tb_co_seguridadlogBL BLL = new tb_co_seguridadlogBL(); tb_co_seguridadlog BEL = new tb_co_seguridadlog(); BEL.moduloid = Name; BEL.clave = VariablesPublicas.EmpresaID + Examinar.Rows[Examinar.CurrentRow.Index].Cells["eventoperid"].Value.ToString(); BEL.cuser = VariablesPublicas.Usuar; BEL.fecha = DateTime.Now; BEL.pc = VariablesPublicas.userip; BEL.accion = "B"; BEL.detalle = "Descripción: " + txtdescripcion.Text.Trim(); BLL.Insert(VariablesPublicas.EmpresaID.ToString(), BEL); Examinar.Rows.Remove(Examinar.CurrentRow); Examinar.Refresh(); u_PintaDatos(); } else { Frm_Class.ShowError(BL.Sql_Error, this); } } } else { Frm_Class.ShowError(BL.Sql_Error, this); } } else { MessageBox.Show(xnomcampo, "IMPOSIBLE ELIMINAR REGISTRO"); } } U_RefrescaControles(); }
private bool ValidaEventos(int fila, bool b) { var prove = string.Empty; var trab = new DataTable(); if ((!object.ReferenceEquals(dgIngresos.Rows[fila].Cells[3].Value, DBNull.Value))) { if (dgIngresos.Rows[fila].Cells[3].Value.ToString() != string.Empty) { var BL = new tb_plla_geneventospermisoBL(); var BE = new tb_plla_geneventospermiso(); prove = VariablesPublicas.FormateaNumeroaCadena2(dgIngresos.Rows[fila].Cells[3].Value.ToString().Trim(), 3, '0', true); dgIngresos.Rows[fila].Cells[3].Value = prove; BE.eventoperid = prove; trab = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; } } if (trab.Rows.Count > 0) { dgIngresos.Rows[dgIngresos.CurrentRow.Index].Cells[4].Value = trab.Rows[0]["eventopername"].ToString().Trim(); return true; } else { if (b) { MessageBox.Show("Codigo no existe !!!"); } return false; } }