示例#1
0
        private void dgvListado_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            // My combobox column is the second one so I hard coded a 1, flavor to taste
            if (balUSUARIO.TieneRegla(SharedData.Instance().getPermiso("VISITA_MODIFICAR"), (SharedData.Instance().Reglas ?? "")))
            {
                if (dgvListado.RowCount > 0 && e.ColumnIndex == 2)
                {
                    //MessageBox.Show(dgvListado.Rows[e.RowIndex].Cells["VIS_dia_semana"].Value.ToString());
                    try
                    {
                        eVISITA oeVISITA = new eVISITA();
                        oeVISITA.ZON_codigo     = Convert.ToInt32(dgvListado.Rows[e.RowIndex].Cells["ZON_codigo"].Value.ToString());
                        oeVISITA.VEN_codigo     = Convert.ToInt32(this.cmbVendedor.SelectedValue.ToString());
                        oeVISITA.VIS_dia_semana = dgvListado.Rows[e.RowIndex].Cells["VIS_dia_semana"].Value.ToString();
                        oeVISITA.VIS_cantidad_clientes_activos = 0;
                        oeVISITA.VIS_estado = "A";

                        if (balVISITA.actualizarRegistro(oeVISITA))
                        {
                            MessageBox.Show("El registro fue actualizado correctamente.", "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            cargarComboZona();
                            cargarGrillaVisita();
                        }
                    }
                    catch (CustomException ex)
                    {
                        MessageBox.Show(ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Ocurrió un error inesperado:\r\n" + ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
        }
示例#2
0
        private void btnAgregar_Click(object sender, EventArgs e)
        {
            //bool rpta = false;
            try
            {
                eVISITA oeVISITA = new eVISITA();
                oeVISITA.ZON_codigo     = Convert.ToInt32(this.cmbZona.SelectedValue.ToString());
                oeVISITA.VEN_codigo     = Convert.ToInt32(this.cmbVendedor.SelectedValue.ToString());
                oeVISITA.VIS_dia_semana = this.cmbDia.Text;
                oeVISITA.VIS_cantidad_clientes_activos = 0;
                oeVISITA.VIS_estado = "A";

                if (balVISITA.insertarRegistro(oeVISITA))
                {
                    MessageBox.Show("El registro fue guardado correctamente.", "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    cargarComboRuta();
                    cargarGrillaVisita();
                }
            }
            catch (CustomException ex)
            {
                MessageBox.Show(ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Ocurrió un error inesperado:\r\n" + ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
示例#3
0
        private void eliminarToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (balUSUARIO.TieneRegla(SharedData.Instance().getPermiso("VISITA_MODIFICAR"), (SharedData.Instance().Reglas ?? "")))
            {
                if (!this.dgvListado.Rows[this.rowIndex].IsNewRow)
                {
                    try
                    {
                        eVISITA oeVISITA = new eVISITA();
                        oeVISITA.ZON_codigo = Convert.ToInt32(dgvListado.Rows[rowIndex].Cells["ZON_codigo"].Value.ToString());
                        oeVISITA.VEN_codigo = Convert.ToInt32(this.cmbVendedor.SelectedValue.ToString());

                        if (balVISITA.eliminarRegistro(oeVISITA))
                        {
                            MessageBox.Show("El registro fue eliminado correctamente.", "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            cargarComboZona();
                            cargarGrillaVisita();
                        }
                    }
                    catch (CustomException ex)
                    {
                        MessageBox.Show(ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Ocurrió un error inesperado:\r\n" + ex.Message, "SICO", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
            }
            else
            {
                MessageBox.Show("Su usuario no tiene permiso para realizar esta operación.", "SICO", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#4
0
        public bool eliminarRegistro(eVISITA oeVISITA)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_crud_VISITA_eliminarRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cnn.Open();

                cmd.Parameters.Add(new SqlParameter("@ZON_CODIGO", oeVISITA.ZON_codigo));
                cmd.Parameters.Add(new SqlParameter("@VEN_CODIGO", oeVISITA.VEN_codigo));

                return(cmd.ExecuteNonQuery() > 0);
            }
        }
示例#5
0
        public DataTable obtenerRegistro(eVISITA oeVISITA)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_crud_VISITA_obtenerRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter dad = new SqlDataAdapter(cmd);
                dad.SelectCommand.Parameters.Add(new SqlParameter("@ZON_CODIGO", oeVISITA.ZON_codigo));
                dad.SelectCommand.Parameters.Add(new SqlParameter("@VEN_CODIGO", oeVISITA.VEN_codigo));

                DataTable dt = new DataTable();
                dad.Fill(dt);

                return(dt);
            }
        }
示例#6
0
        public bool actualizarRegistro(eVISITA oeVISITA)
        {
            using (SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["CadenaPrincipal"].ToString()))
            {
                string     sp  = "pa_crud_VISITA_actualizarRegistro";
                SqlCommand cmd = new SqlCommand(sp, cnn);
                cmd.CommandType = CommandType.StoredProcedure;

                cnn.Open();

                cmd.Parameters.Add(new SqlParameter("@ZON_CODIGO", oeVISITA.ZON_codigo));                                       //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@VEN_CODIGO", oeVISITA.VEN_codigo));                                       //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@VIS_DIA_SEMANA", oeVISITA.VIS_dia_semana));                               //variable tipo:string
                cmd.Parameters.Add(new SqlParameter("@VIS_CANTIDAD_CLIENTES_ACTIVOS", oeVISITA.VIS_cantidad_clientes_activos)); //variable tipo:int
                cmd.Parameters.Add(new SqlParameter("@VIS_ESTADO", oeVISITA.VIS_estado));                                       //variable tipo:string

                return(cmd.ExecuteNonQuery() > 0);
            }
        }