private void btnBuscar_Click(object sender, EventArgs e) { try { if (string.IsNullOrEmpty(cboUsuarios.SelectedValue.ToString().Trim())) { MessageBox.Show("Seleccione un ejecutivo", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboUsuarios.Focus(); return; } CarteraSocioBE oEntity = new CarteraSocioBE() { OPCION = 5, USUARIO = General.General.GetUsuario, UsuarioID = cboUsuarios.SelectedValue.ToString() }; DataSet ds = new DataSet(); ds = new CarteraSocioBL().ProcesarCarteraSocio(oEntity); dgvSocios.DataSource = ds.Tables[0]; lblRegistros.Text = ds.Tables[0].Rows.Count.ToString() + " registro(s)"; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnEliminar_Click(object sender, EventArgs e) { DialogResult dialogResult = 0; try { if (dgvSocios.RowCount > 0) { dialogResult = MessageBox.Show("Seguro de desasignar los socios del usuario", "Confirme", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dialogResult == DialogResult.Yes) { foreach (DataGridViewRow row in dgvSocios.Rows) { CarteraSocioBE oEntity = new CarteraSocioBE() { OPCION = 3, USUARIO = General.General.GetUsuario, IdSocio = row.Cells["IdSocio"].Value.ToString() }; new CarteraSocioBL().ProcesarCarteraSocio(oEntity); } MessageBox.Show("Se Proceso Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); btnBuscar.PerformClick(); } } } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnBuscar_Click(object sender, EventArgs e) { try { //if (string.IsNullOrEmpty(txtIdPagadora.Text.Trim()) && string.IsNullOrEmpty(txtIdSocio.Text.Trim()) && dtFechaInicio.Value == null) //{ // MessageBox.Show("Al menos debe ingresar un filtro", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); // return; //} CarteraSocioBE oEntity = new CarteraSocioBE() { OPCION = 4, USUARIO = General.General.GetUsuario, IdSocio = txtIdSocio.Text, gestorCuentaID = cboEjecutivo.SelectedValue.ToString(), IdPagadora = txtIdPagadora.Text, FechaInicio = dtFechaInicio.Value == null ? DateTime.MinValue : dtFechaInicio.Value, FechaFin = dtFechaFin.Value == null ? DateTime.MinValue : dtFechaFin.Value, FechaInactivo1 = dtFechaInactivo1.Value == null ? DateTime.MinValue : dtFechaInactivo1.Value, FechaInactivo2 = dtFechaInactivo2.Value == null ? DateTime.MinValue : dtFechaInactivo2.Value, NumDias = chkSociosInactivos.Checked ? 1 : 0 }; DataSet ds = new DataSet(); ds = new CarteraSocioBL().ProcesarCarteraSocio(oEntity); dgvSocios.DataSource = ds.Tables[0]; lblNRegistros.Text = ds.Tables[0].Rows.Count.ToString() + " registro(s)"; ((CheckBox)dgvSocios.Controls.Find("ChkSelAsignar", true)[0]).Checked = false; } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public DataSet ProcesarCarteraSocio(CarteraSocioBE BE) { DataSet dsResult; try { cmd = db.GetStoredProcCommand("CarteraSocio_Mnt"); db.AddInParameter(cmd, "OPCION", DbType.Int32, BE.OPCION); db.AddInParameter(cmd, "USUARIO", DbType.String, BE.USUARIO); db.AddInParameter(cmd, "IdSocio", DbType.String, BE.IdSocio); db.AddInParameter(cmd, "IdPagadora", DbType.String, BE.IdPagadora); db.AddInParameter(cmd, "gestorCuentaID", DbType.String, BE.gestorCuentaID); if (BE.FechaInicio != DateTime.MinValue) { db.AddInParameter(cmd, "FechaInicio", DbType.DateTime, BE.FechaInicio); } if (BE.FechaFin != DateTime.MinValue) { db.AddInParameter(cmd, "FechaFin", DbType.DateTime, BE.FechaFin); } if (BE.FechaInactivo1 != DateTime.MinValue) { db.AddInParameter(cmd, "FechaInactivo1", DbType.DateTime, BE.FechaInactivo1); } if (BE.FechaInactivo2 != DateTime.MinValue) { db.AddInParameter(cmd, "FechaInactivo2", DbType.DateTime, BE.FechaInactivo2); } db.AddInParameter(cmd, "NumDias", DbType.Int32, BE.NumDias); db.AddInParameter(cmd, "UsuarioID", DbType.String, BE.UsuarioID); dsResult = db.ExecuteDataSet(cmd); } catch (Exception ex) { throw new Exception(ex.Message); } return(dsResult); }
private void btnNuevo_Click(object sender, EventArgs e) { try { if (dgvSocios.Rows.Count == 0) { MessageBox.Show("Deben existir socios", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboUsuarios.Focus(); return; } if (dgvUsuarios.Rows.Count == 0) { MessageBox.Show("Agregar al menos un usuario para la distribución", "Advertencia", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cboUsuarios.Focus(); return; } int nDistribucion = Math.Abs(dgvSocios.Rows.Count / dgvUsuarios.Rows.Count); int nCountUsuario = dgvUsuarios.Rows.Count; int nRowUsuario = 0; int nCount = 0; foreach (DataGridViewRow row in dgvSocios.Rows) { DataGridViewCheckBoxCell chk = (DataGridViewCheckBoxCell)row.Cells[0]; if (chk.Value != null) { if (chk.Value.ToString().Equals("True")) { if ((nCountUsuario - 1) != nRowUsuario) { if (nCount == nDistribucion) { nRowUsuario += 1; nCount = 0; } } CarteraSocioBE oEntity = new CarteraSocioBE() { OPCION = 2, USUARIO = General.General.GetUsuario, IdSocio = row.Cells["IdSocio"].Value.ToString(), UsuarioID = dgvUsuarios.Rows[nRowUsuario].Cells["gestorID"].Value.ToString(), }; new CarteraSocioBL().ProcesarCarteraSocio(oEntity); nCount += 1; } } } MessageBox.Show("Se Proceso Correctamente", "Mensaje", MessageBoxButtons.OK, MessageBoxIcon.Information); //btnLimpiar.PerformClick(); btnBuscar.PerformClick(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void btnImportar_Click(object sender, EventArgs e) { string srutaArchivo = string.Empty; openFileDialog1.InitialDirectory = @"C:\"; openFileDialog1.Filter = "Archivos de Excel (*.xls) |*.xlsx"; openFileDialog1.FilterIndex = 2; openFileDialog1.RestoreDirectory = true; openFileDialog1.FileName = ""; LstCarteraSocioTmp = new BindingList <CarteraSocioBE>(); if (openFileDialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { srutaArchivo = openFileDialog1.FileName; try { msgHelper.Wait("Cargando registros, espere un momento ..."); cnExcel = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + srutaArchivo + ";Extended Properties='Excel 12.0 Xml;HDR=YES';"); if (cnExcel.State == ConnectionState.Closed) { cnExcel.Open(); } if (!System.IO.File.Exists(srutaArchivo)) { MessageBox.Show("No se encontró el Libro: " + srutaArchivo, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } OleDbDataAdapter daExcel = new OleDbDataAdapter("Select * " + "From [Datos$A1:C20000] ", cnExcel); DataTable dtTable = new DataTable(); daExcel.Fill(dtTable); foreach (DataRow row in dtTable.Rows) { if (!string.IsNullOrEmpty(row["IdSocio"].ToString().Trim()) && !string.IsNullOrEmpty(row["UsuarioID"].ToString().Trim())) { CarteraSocioBE oCarteraSocioBE = new CarteraSocioBE() { OPCION = 2, USUARIO = General.General.GetUsuario, IdSocio = row["IdSocio"].ToString().Trim(), UsuarioID = row["UsuarioID"].ToString().Trim(), IdSocio_Dsc = row["Socio"].ToString().Trim(), }; if (new CarteraSocioBL().ProcesarCarteraSocio(oCarteraSocioBE).Tables[0].Rows.Count > 0) { LstCarteraSocioTmp.Add(oCarteraSocioBE); } } } dgvCargaSocios.DataSource = LstCarteraSocioTmp; cnExcel.Close(); btnImportar.Enabled = false; msgHelper.Wait(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); cnExcel.Close(); msgHelper.Wait(); } } }
public DataSet ProcesarCarteraSocio(CarteraSocioBE BE) { return(CarteraSocioDA.ProcesarCarteraSocio(BE)); }