Exemplo n.º 1
0
        public string Actualizar(BE_Reg_Control oBE_Reg_Control)
        {
            using (SqlConnection sCn = new SqlConnection(ConexionDAO.sConexion))
            {
                sCn.Open();
                SqlTransaction sTrans = sCn.BeginTransaction();
                try
                {
                    string sIdControl = "";

                    sSql = "if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[tmp009]') and OBJECTPROPERTY(id, N'IsUserTable') = 1) drop table [dbo].[tmp009] ";
                    SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);

                    sSql = "select  a.IdControl,a.NroSecuencia,b.IdAreaRecepcion,b.IdOficinaRecepcion,b.IdEmpleadoRecepcion into tmp009 ";
                    sSql += "from   Reg_ControlDetalle a";
                    sSql += "       inner join Reg_ControlDetalle b on a.IdControl = b.IdControl  and b.NroSecuencia = a.NroSecuencia + 1  ";
                    sSql += "where  a.IdCliente='" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and a.IdControl='" + oBE_Reg_Control.IdControl + "' ";
                    SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);

                    sSql = "Update  Reg_ControlDetalle set ";
                    sSql += "       IdOficinaDestinatario=b.IdOficinaRecepcion, ";
                    sSql += "       IdEmpleadoDestinatario=b.IdEmpleadoRecepcion, ";
                    sSql += "       IdAreaDestinatario=b.IdAreaRecepcion ";
                    sSql += "from	Reg_ControlDetalle a ";
                    sSql += "        left join tmp009 b on a.IdControl = b.IdControl and a.NroSecuencia = b.NroSecuencia  ";
                    sSql += "where  a.IdCliente='" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and a.IdControl='" + oBE_Reg_Control.IdControl + "' ";
                    SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);
                    sTrans.Commit();
                    return sIdControl;
                }
                catch (Exception ex) { sTrans.Rollback(); throw ex; }
            }
        }
Exemplo n.º 2
0
        public void ActualizarCodBarra(BE_Reg_Control oBE_Reg_Control)
        {
            using (SqlConnection sCn = new SqlConnection(ConexionDAO.sConexion))
            {
                sCn.Open();
                SqlTransaction sTrans = sCn.BeginTransaction();
                try
                {
                    sSql = "update Reg_Control set ";
                    sSql += "       codbarra = '" + oBE_Reg_Control.CodBarra  + "' ";
                    sSql += "where  IdCliente = '" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and IdControl = '" + oBE_Reg_Control.IdControl + "' ";
                    SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);

                }
                catch (Exception ex) { sTrans.Rollback(); throw ex; }
            }
        }
Exemplo n.º 3
0
        private void txtIdControl_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == 13)
                {
                    //txtIdControl.Text = txtIdControl.Text.Trim().Substring(1, 8);
                    oBE_Reg_Control = oBL_Reg_Control.Get_Control(txtIdControl.Text);
                    if (oBE_Reg_Control != null)
                    {
                        lblIdTipoDocumento.Text = oBE_Reg_Control.IdTipoDocumento;
                        lblDesTipoDocumento.Text = oBL_T_TipoDocumento.Get_Descripcion(lblIdTipoDocumento.Text);

                        lblIdMaestroCliente.Text = oBE_Reg_Control.IdMaestroCliente;
                        lblDesMaestroCliente.Text = oBL_T_MaestroCliente.Get_RazonSocial(lblIdMaestroCliente.Text);

                        lblNroDocumento.Text = oBE_Reg_Control.NroDocumento;
                        lblFechaDocumento.Text = oBE_Reg_Control.FechaDocumento.ToString("dd/MM/yyyy");
                        txtObservacionGeneral.Text = oBE_Reg_Control.Observacion;

                        string sActividadPendiente = oBL_Reg_Control.ActividadPendiente(txtIdControl.Text);
                        if (sActividadPendiente == "")
                        {
                            MessageBox.Show("No hay Actividades Pendientes de Envío. Verificar", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            BtnGrabar.Visible = false; txtIdControl.Focus(); return;
                        }

                        oBE_Reg_ControlDetalle = oBL_Reg_Control.Get_ControlDetalleRecepcion(txtIdControl.Text);

                        if (oBE_Reg_ControlDetalle != null)
                        {
                            lblIdActividad.Text = oBE_Reg_ControlDetalle.IdActividad;
                            lblDesActividad.Text = oBL_T_Actividad.Get_Descripcion(lblIdActividad.Text);
                            lblIdOficinaRecepcion.Text = oBE_Reg_ControlDetalle.IdOficinaRecepcion;
                            lblDesOficinaRecepcion.Text = oBL_T_Oficina.Get_Descripcion(lblIdOficinaRecepcion.Text);
                            lblFechaRecepcion.Text = oBE_Reg_ControlDetalle.FechaRecepcion.ToString("dd/MM/yyyy");
                            lblHoraRecepcion.Text = oBE_Reg_ControlDetalle.FechaRecepcion.ToString("hh:mm tt");
                            txtObservacion.Text = oBE_Reg_ControlDetalle.Observacion;
                            txtIdOficinaDestinatario.Text = oBE_Reg_ControlDetalle.IdOficinaDestinatario ;
                            txtIdArea.Text = oBE_Reg_ControlDetalle.IdAreaDestinatario ;
                            lblIdEmpleado.Text = oBE_Reg_ControlDetalle.IdEmpleadoDestinatario ;
                        }
                        else
                        {
                            MessageBox.Show("Ya no hay mas actividades para este control. Verificar", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            BtnGrabar.Visible = false; txtIdControl.Focus(); return;
                        }

                        lblFechaEnvio.Text = DateTime.Now.ToString("dd/MM/yyyy");
                        lblHoraEnvio.Text = DateTime.Now.ToString("hh:mm tt");
                        txtIdOficinaDestinatario.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Control No Existe. Verificar", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtIdControl.Focus(); return;
                    }
                }
            }
            catch (Exception Er)
            { MessageBox.Show(this, Er.Message, "Error : " + Er.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
        private void txtIdControl_KeyPress(object sender, KeyPressEventArgs e)
        {
            try
            {
                if (e.KeyChar == 13)
                {
                    //txtIdControl.Text = txtIdControl.Text.Trim().Substring(1, 8);
                    oBE_Reg_Control = oBL_Reg_Control.Get_Control(txtIdControl.Text);
                    if (oBE_Reg_Control != null)
                    {

                        lblIdTipoDocumento.Text = oBE_Reg_Control.IdTipoDocumento;
                        lblDesTipoDocumento.Text = oBL_T_TipoDocumento.Get_Descripcion(lblIdTipoDocumento.Text);
                        lblIdMaestroCliente.Text = oBE_Reg_Control.IdMaestroCliente;
                        lblDesMaestroCliente.Text = oBL_T_MaestroCliente.Get_RazonSocial(lblIdMaestroCliente.Text);
                        lblNroDocumento.Text = oBE_Reg_Control.NroDocumento;
                        lblFechaDocumento.Text = oBE_Reg_Control.FechaDocumento.ToString("dd/MM/yyyy");
                        txtObservacionGeneral.Text = oBE_Reg_Control.Observacion;

                        string sActividadPendiente = oBL_Reg_Control.ActividadPendiente(txtIdControl.Text);
                        if (sActividadPendiente != "")
                        {
                            MessageBox.Show("Existe una Actividad Pendiente de Envío : " + sActividadPendiente + " . Verificar", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            BtnGrabar.Visible = false; txtIdControl.Focus(); return;
                        }

                        oBE_Reg_ControlDetalle = oBL_Reg_Control.Get_ControlDetalleRecepcion(txtIdControl.Text);

                        if (oBE_Reg_ControlDetalle != null)
                        {
                            lblIdActividad.Text = oBE_Reg_ControlDetalle.IdActividad;
                            lblDesActividad.Text = oBL_T_Actividad.Get_Descripcion(lblIdActividad.Text);
                        }
                        else
                        {
                            MessageBox.Show("Ya no hay mas actividades para este control. Verificar", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            BtnGrabar.Visible = false; txtIdControl.Focus(); return;
                        }

                        //Validando Actividad con empleado
                        string sIdEmpleado = oBL_Sis_Usuario.Get_IdEmpleado(BE_Helper.oBE_Sis_Usuario.IdUsuario);
                        if (oBL_Reg_Control.Empleado_Valido_Recepcion(sIdEmpleado, lblIdActividad.Text) == false)
                        {
                            MessageBox.Show("Ud. no está autorizado para recepcionar este documento en esta actividad. Verificar", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            BtnGrabar.Visible = false; txtIdControl.Focus(); return;
                        }

                        oBE_T_Empleado = oBL_T_Empleado.Get_Empleado(sIdEmpleado);

                        //Buscando Datos de Recepcion con respecto al Empleado

                        lblFechaRecepcion.Text = DateTime.Now.ToString("dd/MM/yyyy");
                        lblHoraRecepcion.Text = DateTime.Now.ToString("hh:mm tt");
                        lblIdEmpleado.Text = sIdEmpleado;
                        lblDesEmpleado.Text = oBE_T_Empleado.Nombre;
                        lblIdOficinaRecepcion.Text = oBE_T_Empleado.IdOficina;
                        lblDesOficinaRecepcion.Text = oBL_T_Oficina.Get_Descripcion(lblIdOficinaRecepcion.Text);
                        lblIdAreaRecepcion.Text = oBE_T_Empleado.IdArea;
                        lblDesAreaRecepcion.Text = oBL_T_Area.Get_Descripcion(lblIdAreaRecepcion.Text);

                        txtObservacion.Focus();
                    }
                    else
                    {
                        MessageBox.Show("Control No Existe. Verificar", "Validación", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                        txtIdControl.Focus(); return;
                    }
                }
            }
            catch (Exception Er)
            { MessageBox.Show(this, Er.Message, "Error : " + Er.Source.ToString(), MessageBoxButtons.OK, MessageBoxIcon.Error); }
        }
Exemplo n.º 5
0
 public string Insertar(BE_Reg_Control oBE_Reg_Control)
 {
     return oDL_Reg_Control.Insertar(oBE_Reg_Control);
 }
Exemplo n.º 6
0
 public void ActualizarCodBarra(BE_Reg_Control oBE_Reg_Control)
 {
     oDL_Reg_Control.ActualizarCodBarra(oBE_Reg_Control);
 }
Exemplo n.º 7
0
 public string Actualizar(BE_Reg_Control oBE_Reg_Control)
 {
     return oDL_Reg_Control.Actualizar(oBE_Reg_Control);
 }
Exemplo n.º 8
0
 public void Modificar(BE_Reg_Control oBE_Reg_Control)
 {
     oDL_Reg_Control.Modificar(oBE_Reg_Control);
 }
Exemplo n.º 9
0
        protected virtual BE_Reg_Control Make(DataTable dt)
        {
            if (dt.Rows.Count <= 0) return null;

            BE_Reg_Control oBE_Reg_Control = new BE_Reg_Control();
            oBE_Reg_Control.IdCliente = dt.Rows[0]["IdCliente"].ToString().Trim();
            oBE_Reg_Control.IdControl = dt.Rows[0]["IdControl"].ToString().Trim();
            oBE_Reg_Control.FechaRecepcion = (DateTime)dt.Rows[0]["FechaRecepcion"];
            oBE_Reg_Control.IdOficinaRecepcion = dt.Rows[0]["IdOficinaRecepcion"].ToString().Trim();
            oBE_Reg_Control.IdTipoDocumento = dt.Rows[0]["IdTipoDocumento"].ToString().Trim();
            oBE_Reg_Control.IdMaestroCliente = dt.Rows[0]["IdMaestroCliente"].ToString().Trim();
            oBE_Reg_Control.NroDocumento = dt.Rows[0]["NroDocumento"].ToString().Trim();
            oBE_Reg_Control.FechaDocumento = (DateTime)dt.Rows[0]["FechaDocumento"];
            oBE_Reg_Control.Observacion = dt.Rows[0]["Observacion"].ToString().Trim();
            if (dt.Rows[0]["FechaInicio"].ToString() != "") oBE_Reg_Control.FechaInicio = (DateTime)dt.Rows[0]["FechaInicio"];
            if (dt.Rows[0]["FechaTermino"].ToString() != "") oBE_Reg_Control.FechaTermino = (DateTime)dt.Rows[0]["FechaTermino"];
            oBE_Reg_Control.Estado = dt.Rows[0]["Estado"].ToString().Trim();
            oBE_Reg_Control.IdRuta = dt.Rows[0]["IdRuta"].ToString().Trim();
            oBE_Reg_Control.FechaRegistro = (DateTime)dt.Rows[0]["FechaRegistro"];
            oBE_Reg_Control.HoraRegistro = dt.Rows[0]["HoraRegistro"].ToString().Trim();
            oBE_Reg_Control.UsuarioRegistro = dt.Rows[0]["UsuarioRegistro"].ToString().Trim();
            return oBE_Reg_Control;
        }
Exemplo n.º 10
0
        public void Modificar(BE_Reg_Control oBE_Reg_Control)
        {
            using (SqlConnection sCn = new SqlConnection(ConexionDAO.sConexion))
            {
                sCn.Open();
                SqlTransaction sTrans = sCn.BeginTransaction();
                try
                {
                    sSql = "update	Reg_Control set ";
                    sSql += "       IdTipoDocumento= '" + oBE_Reg_Control.IdTipoDocumento + "',  ";
                    sSql += "       IdMaestroCliente= '" + oBE_Reg_Control.IdMaestroCliente + "', ";
                    sSql += "       NroDocumento= '" + oBE_Reg_Control.NroDocumento + "', ";
                    sSql += "       FechaDocumento= '" + oBE_Reg_Control.FechaDocumento.ToString("yyyy/MM/dd") + "', ";
                    sSql += "       Observacion= '" + oBE_Reg_Control.Observacion + "' ";
                    //sSql += "       IdRuta= @IdRuta ";
                    sSql += "where	IdCliente=@IdCliente and IdControl=@IdControl ";

                    SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);
                    sTrans.Commit();
                }
                catch (Exception ex) { sTrans.Rollback(); throw ex; }
            }
        }
Exemplo n.º 11
0
        public string Insertar(BE_Reg_Control oBE_Reg_Control)
        {
            using (SqlConnection sCn = new SqlConnection(ConexionDAO.sConexion))
            {
                sCn.Open();
                SqlTransaction sTrans = sCn.BeginTransaction();
                try
                {
                    string sIdControl = ""; string sCorrelativo = "";

                    sSql = "select  right('00000'+convert(varchar(5),Correlativo+1),5) ";
                    sSql += "from   T_Numeracion ";
                    sSql += "where  IdCliente='" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and Año='" + oBE_Reg_Control.FechaRecepcion.ToString("yyyy") + "' and IdOficina='" + oBE_Reg_Control.IdOficinaRecepcion + "'";
                    sCorrelativo = Convert.ToString(SqlHelper.ExecuteScalar(sTrans, CommandType.Text, sSql));
                    if (sCorrelativo == "")
                    {
                        sCorrelativo = "00001";
                        sSql = "insert  into T_Numeracion values (";
                        sSql += "       '" + BE_Helper.oBE_Sis_Cliente.IdCliente + "','" + oBE_Reg_Control.FechaRecepcion.ToString("yyyy") + "','" + oBE_Reg_Control.IdOficinaRecepcion + "','" + sCorrelativo + "') ";
                        SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);
                    }
                    else
                    {
                        sSql = "update  T_Numeracion set ";
                        sSql += "       correlativo = '" + sCorrelativo + "' ";
                        sSql += "where  IdCliente = '" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and Año = '" + oBE_Reg_Control.FechaRecepcion.ToString("yyyy") + "' and IdOficina='" + oBE_Reg_Control.IdOficinaRecepcion + "' ";
                        SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);
                    }

                    //sIdControl = oBE_Reg_Control.FechaRecepcion.ToString("yyyy") + oBE_Reg_Control.IdOficinaRecepcion.Trim() + sCorrelativo;
                    sIdControl = oBE_Reg_Control.FechaRecepcion.ToString("yy") + oBE_Reg_Control.IdOficinaRecepcion.Trim().Substring(0,1) + sCorrelativo;
                    sSql = "INSERT	INTO Reg_Control VALUES( ";
                    sSql += "       '" + BE_Helper.oBE_Sis_Cliente.IdCliente + "', ";
                    sSql += "       '" + sIdControl + "', ";
                    //sSql += "       '" + oBE_Reg_Control.FechaRecepcion.ToString("yyyyMMdd HH':'mm':'s")  + "',  ";
                    sSql += " convert(varchar,getdate(),112)+' '+convert(varchar,getdate(),108), ";
                    sSql += "       '" + oBE_Reg_Control.IdOficinaRecepcion + "',  ";
                    sSql += "       '" + oBE_Reg_Control.IdTipoDocumento + "',  ";
                    sSql += "       '" + oBE_Reg_Control.IdRuta + "', ";
                    sSql += "       '" + oBE_Reg_Control.IdMaestroCliente + "', ";
                    sSql += "       '" + oBE_Reg_Control.NroDocumento + "', ";
                    sSql += "       '" + oBE_Reg_Control.FechaDocumento.ToString("yyyyMMdd") + "', ";
                    sSql += "       '" + oBE_Reg_Control.Observacion + "', ";
                    sSql += "       null, ";
                    sSql += "       null, ";
                    sSql += "       null, ";
                    sSql += "       '" + oBE_Reg_Control.CodBarra + "', ";
                    sSql += "       'Pendiente', ";
                    sSql += "       convert(varchar,getdate(),112),convert(varchar,getdate(),108),'" + BE_Helper.oBE_Sis_Usuario.IdUsuario + "') ";
                    SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);

                    //sSql = "insert into Reg_ControlDetalle ";
                    //sSql += "select	a.IdCliente,'" + sIdControl + "',right(0+convert(varchar(2),Orden),2),Orden, ";
                    //sSql += "       IdActividad, ";
                    //sSql += "       null,null,null,null, ";
                    //sSql += "       null,null,null,null, ";
                    //sSql += "       '',a.DuracionEnDias,'Pendiente', ";
                    //sSql += "       convert(varchar,getdate(),112),convert(varchar,getdate(),108),'" + BE_Helper.oBE_Sis_Usuario.IdUsuario + "' ";
                    //sSql += "from	T_RutaActividad a  ";
                    //sSql += "where	a.IdCliente='" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and a.IdRuta='" + oBE_Reg_Control.IdRuta + "' ";
                    //SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);

                    sSql = "insert into Reg_ControlDetalle ";
                    sSql += "select	a.IdCliente,'" + sIdControl + "',right(0+convert(varchar(2),Orden),2),Orden, ";
                    sSql += "       a.IdActividad, ";
                    sSql += "       a.IdOficina,b.IdEmpleadoResponsable,a.IdArea,null, ";
                    sSql += "       null,null,null,null, ";
                    sSql += "       '',a.DuracionEnDias,'Pendiente', ";
                    sSql += "       convert(varchar,getdate(),112),convert(varchar,getdate(),108),'" + BE_Helper.oBE_Sis_Usuario.IdUsuario + "' ";
                    sSql += "from	T_RutaActividad a  ";
                    sSql += "       left join T_Area b on a.IdArea = b.IdArea  ";
                    sSql += "where	a.IdCliente='" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and a.IdRuta='" + oBE_Reg_Control.IdRuta + "' ";
                    SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);

                    sSql = "select  IdEmpleado ";
                    sSql += "from   Sis_Usuario ";
                    sSql += "where  IdCliente='" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and IdUsuario='" + BE_Helper.oBE_Sis_Usuario.IdUsuario + "'";
                    string sIdEmpleado = Convert.ToString(SqlHelper.ExecuteScalar(sTrans, CommandType.Text, sSql));

                    sSql = "select  IdArea ";
                    sSql += "from   T_Empleado ";
                    sSql += "where  IdCliente='" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and IdEmpleado='" + sIdEmpleado + "'";
                    string sIdArea = Convert.ToString(SqlHelper.ExecuteScalar(sTrans, CommandType.Text, sSql));

                    sSql = "Update  Reg_ControlDetalle set ";
                    sSql += "       IdOficinaRecepcion='" + oBE_Reg_Control.IdOficinaRecepcion + "', ";
                    sSql += "       IdEmpleadoRecepcion='" + sIdEmpleado + "', ";
                    sSql += "       IdAreaRecepcion='" + sIdArea + "', ";
                    sSql += "       FechaRecepcion = convert(varchar,getdate(),112)+' '+convert(varchar,getdate(),108) ";
                    //sSql += "       FechaRecepcion='" + oBE_Reg_Control.FechaRecepcion.ToString("yyyyMMdd HH':'mm':'s") + "'  ";
                    sSql += "where	IdCliente='" + BE_Helper.oBE_Sis_Cliente.IdCliente + "' and IdControl='" + sIdControl + "' and NroSecuencia=1 ";
                    SqlHelper.ExecuteNonQuery(sTrans, CommandType.Text, sSql);

                    sTrans.Commit();
                    return sIdControl;
                }
                catch (Exception ex) { sTrans.Rollback(); throw ex; }
            }
        }