private void Accion(int naccion) { switch (naccion) { case 1: u_n_opsel = 1; U_RefrescaControles(); Blanquear(); var BL = new tb_plla_plantilla_contratosBL(); var BE = new tb_plla_plantilla_contratos(); txtcodigo.Text = BL.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BE).Tables[0].Rows[0]["maximo_codigo"].ToString(); if (Examinar.CurrentRow != null) { Examinar.CurrentRow.Selected = false; } break; case 2: POnedatos(); u_n_opsel = 2; U_RefrescaControles(); Examinar.CurrentRow.Selected = true; break; case 3: xnomcampo = ""; if (Examinar.CurrentRow != null) { var BLIR = new tb_plla_plantilla_contratosBL(); var BEIR = new tb_plla_plantilla_contratos(); BEIR.plantillaid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["plantillaid"].Value.ToString().Trim(); tmpcursor = BLIR.GetAll_CONSULTAIR(VariablesPublicas.EmpresaID, BEIR).Tables[0]; if (BLIR.Sql_Error.Length > 0) { xnomcampo = BLIR.Sql_Error; Frm_Class.ShowError(BLIR.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) { var message = "Desea Eliminar Registro " + Examinar.Rows[Examinar.CurrentRow.Index].Cells["plantillaid"].Value.ToString().Trim() + "-" + Examinar.Rows[Examinar.CurrentRow.Index].Cells["plantillaname"].Value.ToString().Trim() + " ...?"; var caption = "Mensaje del Sistema"; var buttons = MessageBoxButtons.YesNo; DialogResult result; result = MessageBox.Show(this, message, caption, buttons, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2); if (result == DialogResult.Yes) { var BLE = new tb_plla_plantilla_contratosBL(); var BEE = new tb_plla_plantilla_contratos(); BEE.plantillaid = Examinar.Rows[Examinar.CurrentRow.Index].Cells["plantillaid"].Value.ToString().Trim(); BEE.norden = 1; BEE.ver_blanco = 0; BEE.vista = 1; tmpcursor = BLE.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BEE).Tables[0]; if (BLE.Sql_Error.Length == 0) { if (BLE.Eliminar(VariablesPublicas.EmpresaID, tmpcursor)) { for (lc_cont = 0; lc_cont <= Tabla.Rows.Count - 1; lc_cont++) { if (Tabla.Rows[lc_cont]["plantillaid"] == Examinar.Rows[Examinar.CurrentRow.Index].Cells["plantillaid"].Value) { Tabla.Rows[lc_cont].Delete(); Tabla.AcceptChanges(); break; } } Examinar.Refresh(); } else { Frm_Class.ShowError(BLE.Sql_Error, this); } } else { Frm_Class.ShowError(BLE.Sql_Error, this); } } } else { MessageBox.Show(xnomcampo, "IMPOSIBLE ELIMINAR DOCUMENTO"); } break; } }
private void save() { if (u_Validate()) { tmpcursor = null; var BL = new tb_plla_plantilla_contratosBL(); var BE = new tb_plla_plantilla_contratos(); BE.norden = 1; BE.ver_blanco = 0; BE.vista = 1; tmpcursor = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; var ofila = tmpcursor.NewRow(); ofila = VariablesPublicas.InsertIntoTable(tmpcursor); if (u_n_opsel == 1) { BE.plantillaid = txtcodigo.Text.Trim(); tmptabla = BL.GetAll_CONSULTA(VariablesPublicas.EmpresaID, BE).Tables[0]; if (tmptabla.Rows.Count > 0) { var BLMX = new tb_plla_plantilla_contratosBL(); var BEMX = new tb_plla_plantilla_contratos(); ofila["plantillaid"] = BLMX.GetAll_MaxCodigo(VariablesPublicas.EmpresaID.ToString(), BEMX).Tables[0].Rows[0]["maximo_codigo"].ToString(); } else { ofila["plantillaid"] = txtcodigo.Text; } } else { ofila["plantillaid"] = Examinar.Rows[Examinar.CurrentRow.Index].Cells["plantillaid"].Value; for (lc_cont = 0; lc_cont <= Examinar.ColumnCount - 1; lc_cont++) { xnomcampo = Examinar.Columns[lc_cont].Name; ofila[xnomcampo] = Examinar.Rows[Examinar.CurrentRow.Index].Cells[lc_cont].Value; } } ofila["plantillaid"] = txtcodigo.Text.Trim(); ofila["plantillaname"] = txtdescripcion.Text.Trim(); ofila["plantilladoc"] = txtnombrearchivo.Text.Trim(); ofila["tipocontratoid"] = cmb_tipocontrato.SelectedValue.ToString(); ofila["tipoestado"] = cmb_tipoestado.SelectedValue.ToString(); ofila["plantillaword"] = vmContenidoFile; tmpcursor.Rows.Add(ofila); if (BL.Insert_Update(VariablesPublicas.EmpresaID, BE, tmpcursor)) { U_CancelarEdicion(0); } else { Frm_Class.ShowError(BL.Sql_Error, this); } } }