Example #1
0
        private void ListarHojas()
        {
            HojaServicio hoja = new HojaServicio();

            hoja.NumHojaServicio = Utilidades.ToInt(txtNumeroHoja.Text);
            hoja.idServicio      = Utilidades.ToInt(cboservicio.SelectedValue);
            hoja.FechaInicial    = txtfechaInicio.Text;
            hoja.FechaFinal      = txtFechaFin.Text;
            hoja.idCliente       = Utilidades.ToInt(txtcodigocliente.Text);
            hoja.NombreCliente   = txtnombrecliente.Text;

            DataTable data = AtencionPeluqueriaBuss.BusquedaHojaServicio(hoja);

            if (data.Rows.Count == 0)
            {
                lblmsg.Text = "Sin registros para mostrar";
            }
            else
            {
                lblmsg.Text = "";
            }

            this.grvresultado.DataSource = data;
            this.grvresultado.DataBind();
        }
        //Modificar de hoja de servicio
        public static void ModificarHojaServicio(HojaServicio objParam, SqlTransaction objTx)
        {
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = "usp_HojaServicio_u";

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = objTx.Connection;
                cmd.Transaction = objTx;

                cmd.Parameters.Add(new SqlParameter("@idHojaServicio", SqlDbType.Int)).Value = objParam.idHojaServicio;
                if (objParam.FechaEmision != string.Empty)
                {
                    cmd.Parameters.Add(new SqlParameter("@FechaEmision", SqlDbType.Date)).Value = objParam.FechaEmision;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@FechaEmision", SqlDbType.Date)).Value = DBNull.Value;
                }

                cmd.Parameters.Add(new SqlParameter("@Observaciones", SqlDbType.VarChar, 250)).Value = objParam.Observaciones;

                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                cmd = null;
            }
        }
        //ingreso de hoja de servicio
        public static string InsertarHojaServicio(HojaServicio objParam, SqlTransaction objTx)
        {
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = "usp_HojaServicio_i";

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = objTx.Connection;
                cmd.Transaction = objTx;

                cmd.Parameters.Add(new SqlParameter("@idcita", SqlDbType.Int)).Value                 = objParam.idCita;
                cmd.Parameters.Add(new SqlParameter("@idEmpleado", SqlDbType.Int)).Value             = objParam.idEmpleado;
                cmd.Parameters.Add(new SqlParameter("@numhojaservicio", SqlDbType.Int)).Value        = objParam.NumHojaServicio;
                cmd.Parameters.Add(new SqlParameter("@Observaciones", SqlDbType.VarChar, 250)).Value = objParam.Observaciones;
                cmd.Parameters.Add(new SqlParameter("@fechaRegistro", SqlDbType.Date)).Value         = objParam.FechaEmision;
                cmd.Parameters.Add(new SqlParameter("@Canil", SqlDbType.Char, 3)).Value              = objParam.Canil;
                cmd.ExecuteNonQuery();

                return(string.Empty);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                cmd = null;
            }
        }
        //Grabar Hoja de servicio
        public static string GrabarHojaServicio(HojaServicio objParam, List <DetalleServicio> detalle, int accion)
        {
            string conn = System.Configuration.ConfigurationManager.ConnectionStrings["database"].ToString();

            SqlConnection  cnnDS     = new SqlConnection();
            SqlTransaction txOle     = null;
            string         Resultado = string.Empty;

            try
            {
                cnnDS.ConnectionString = conn;
                cnnDS.Open();
                txOle = cnnDS.BeginTransaction();

                if (accion == 1)
                {
                    Resultado = AtencionPeluqueriaDAO.InsertarHojaServicio(objParam, txOle);
                }
                else if (accion == 3)
                {
                    AtencionPeluqueriaDAO.AnularHojaServicio(objParam, txOle);
                }
                else if (accion == 2)
                {
                    //update detalle
                    for (Int32 pp = 0; pp <= detalle.Count - 1; pp++)
                    {
                        AtencionPeluqueriaDAO.ActualizarDetalleHojaServicio(detalle[pp], txOle);
                    }

                    //update cabecera
                    AtencionPeluqueriaDAO.ModificarHojaServicio(objParam, txOle);
                }


                txOle.Commit();
                cnnDS.Close();
                return(Resultado);
            }
            catch (Exception ex)
            {
                txOle.Rollback();
                cnnDS.Close();
                throw;
                return(string.Empty);
            }
            finally
            {
                cnnDS = null;
                txOle = null;
            }
        }
Example #5
0
        /// <summary>
        ///
        /// </summary>
        /// <remarks></remarks>
        /// <param name="objParam"></param>
        /// <param name="detalle"></param>
        /// <param name="accion"></param>
        /// <returns></returns>
        public static string GrabarHojaServicio(HojaServicio objParam, List <DetalleServicio> detalle, int accion)
        {
            string Conn = System.Configuration.ConfigurationManager.ConnectionStrings["database"].ToString();

            SqlConnection  CnnDS     = new SqlConnection();
            SqlTransaction TxOle     = null;
            string         Resultado = string.Empty;

            try
            {
                CnnDS.ConnectionString = Conn;
                CnnDS.Open();
                TxOle = CnnDS.BeginTransaction();

                if (accion == Utilitario.Comun.AccionHojaServicio.Insertar)
                {
                    Resultado = AtencionPeluqueriaDAO.InsertarHojaServicio(objParam, TxOle);
                }
                else if (accion == Utilitario.Comun.AccionHojaServicio.Anular)
                {
                    AtencionPeluqueriaDAO.AnularHojaServicio(objParam, TxOle);
                }
                else if (accion == Utilitario.Comun.AccionHojaServicio.Actualizar)
                {
                    //update detalle
                    for (Int32 pp = 0; pp <= detalle.Count - 1; pp++)
                    {
                        AtencionPeluqueriaDAO.ActualizarDetalleHojaServicio(detalle[pp], TxOle);
                    }

                    //update cabecera
                    AtencionPeluqueriaDAO.ModificarHojaServicio(objParam, TxOle);
                }


                TxOle.Commit();
                CnnDS.Close();
                return(Resultado);
            }
            catch
            {
                TxOle.Rollback();
                CnnDS.Close();
                throw;
            }
            finally
            {
                CnnDS = null;
                TxOle = null;
            }
        }
Example #6
0
        protected void btngrabar_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtcodigocliente.Text == string.Empty)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert('Debe realizar primero la busqueda de la cita.')", true);
                    return;
                }

                int     idcita = Utilidades.ToInt(txtcodigocita.Text);
                DataSet data   = AtencionPeluqueriaBuss.GetDatosCita(idcita);


                if (data.Tables[0].Rows.Count > 0)
                {
                    txtcodigocliente.Text  = data.Tables[0].Rows[0]["idcliente"].ToString();
                    txtnombrecliente.Text  = data.Tables[0].Rows[0]["NombreCliente"].ToString();
                    txtcodigomascota.Text  = data.Tables[0].Rows[0]["idMascota"].ToString();
                    txtnombremascota.Text  = data.Tables[0].Rows[0]["nombreMascota"].ToString();
                    txtespeciemascota.Text = data.Tables[0].Rows[0]["descripcionEspecie"].ToString();
                    txtedadmascota.Text    = data.Tables[0].Rows[0]["Edad"].ToString();
                    txtsexomascota.Text    = data.Tables[0].Rows[0]["DscSexoMascota"].ToString();
                    txttamañomascota.Text  = data.Tables[0].Rows[0]["tamaño"].ToString();

                    //detalle

                    this.grvresultado.DataSource = data.Tables[1];
                    this.grvresultado.DataBind();
                }
                else
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert('La cita para el código ingresado no existe, o no esta pendiente.')", true);
                    return;
                }

                HojaServicio hoja = new HojaServicio();
                hoja.idEmpleado      = 1;
                hoja.FechaEmision    = txtfecharegistro.Text;
                hoja.NumHojaServicio = 0;
                hoja.Canil           = cbojaula.SelectedValue;
                hoja.idCita          = Utilidades.ToInt(txtcodigocita.Text);
                hoja.Observaciones   = txtobservaciones.Text.ToUpper();
                AtencionPeluqueriaBuss.GrabarHojaServicio(hoja, null, 1);
                Response.Redirect("ActualizarHojaServicio.aspx");
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Error interno del sistema.'});", true);
            }
        }
        public static void AnularHojaServicio(HojaServicio objParam, SqlTransaction objTx)
        {
            SqlCommand cmd = new SqlCommand();

            try
            {
                cmd.CommandText = "usp_HojaServicio_d";

                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = objTx.Connection;
                cmd.Transaction = objTx;

                cmd.Parameters.Add(new SqlParameter("@idHojaServicio", SqlDbType.Int)).Value = objParam.idHojaServicio;
                cmd.ExecuteNonQuery();
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                cmd = null;
            }
        }
Example #8
0
 /// <summary>
 ///
 /// </summary>
 /// <remarks></remarks>
 /// <param name="hoja"></param>
 /// <returns></returns>
 public static DataTable BusquedaHojaServicio(HojaServicio hoja)
 {
     return(AtencionPeluqueriaDAO.BusquedaHojaServicio(hoja));
 }
Example #9
0
        protected void grvresultado_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //EJECUTAR
            if (e.CommandName == "Ejecutar")
            {
                int idHoja = Utilidades.ToInt(e.CommandArgument.ToString());
                try
                {
                    DataSet data = AtencionPeluqueriaBuss.GetDatosHojaServicioEjecutar(idHoja);


                    if (data.Tables[0].Rows.Count > 0)
                    {
                        hfidHojaServicio.Value        = data.Tables[0].Rows[0]["idHojaServicio"].ToString();
                        txtfechaemisionalt.Text       = data.Tables[0].Rows[0]["fechaRegistro"].ToString();
                        txtobservacionesejecutar.Text = data.Tables[0].Rows[0]["Observaciones"].ToString();

                        //detalle

                        this.grvResultadoPopup.DataSource = data.Tables[1];
                        this.grvResultadoPopup.DataBind();


                        lblModalTitle.Text = "Ejecutar Hoja de servicio";
                        ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal();", true);
                        upModal.Update();
                    }
                    else
                    {
                        ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "alert('No existe servicios agregados en la Hoja de servicio')", true);
                    }
                }
                catch (Exception ex)
                {
                    //this.lblmsg.Text = ex.Message;
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Error interno del sistema.'});", true);
                }

                //EDITAR
            }

            else if (e.CommandName == "Anular")
            {
                try
                {
                    int         idHoja   = Utilidades.ToInt(e.CommandArgument.ToString());
                    GridViewRow gvr      = (GridViewRow)((ImageButton)e.CommandSource).NamingContainer;
                    int         RowIndex = gvr.RowIndex;

                    HojaServicio hoja = new HojaServicio()
                    {
                        idHojaServicio = idHoja
                    };
                    AtencionPeluqueriaBuss.GrabarHojaServicio(hoja, (new List <DetalleServicio>()), 3);
                    ListarHojas();
                }
                catch (Exception ex)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Error interno del sistema.'});", true);
                }
            }
        }
Example #10
0
        protected void btngrabarejecutar_Click(object sender, EventArgs e)
        {
            try
            {
                //Validando campos obligatorios
                if (txtfechaemisionalt.Text == string.Empty)
                {
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Ingrese la fecha de emisión.'});", true);
                    return;
                }
                //Guardando cabecera
                HojaServicio hoja = new HojaServicio();
                hoja.idHojaServicio = Utilidades.ToInt(hfidHojaServicio.Value);
                hoja.FechaEmision   = txtfechaemisionalt.Text;
                hoja.Observaciones  = txtobservacionesejecutar.Text;

                //Guardando detalles
                List <DetalleServicio> lista    = new List <DetalleServicio>();
                DropDownList           ddestado = default(DropDownList);
                DropDownList           empleado = default(DropDownList);
                TextBox txthorainicio           = default(TextBox);
                TextBox txthorafin = default(TextBox);

                DetalleServicio item = null;
                for (Int32 i = 0; i <= grvResultadoPopup.Rows.Count - 1; i++)
                {
                    item = new DetalleServicio();

                    item.iddetalleHojaServicio = Utilidades.ToInt(this.grvResultadoPopup.DataKeys[i].Values[0].ToString());
                    ddestado      = (DropDownList)grvResultadoPopup.Rows[i].FindControl("cboEstadoser");
                    empleado      = (DropDownList)grvResultadoPopup.Rows[i].FindControl("cboEmpleadoServ");
                    txthorainicio = (TextBox)grvResultadoPopup.Rows[i].FindControl("txtHorainicio");
                    txthorafin    = (TextBox)grvResultadoPopup.Rows[i].FindControl("txtHoraFin");

                    if (ddestado.SelectedValue == "002")
                    {
                        if (txthorainicio.Text == string.Empty)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Ingrese la hora de inicio.'});", true);
                            return;
                        }

                        if (txthorafin.Text == string.Empty)
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Ingrese la hora de Fin.'});", true);
                            return;
                        }

                        if (empleado.SelectedValue == "0")
                        {
                            ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Seleccione el empleado que ejecuto el servicio.'});", true);
                            return;
                        }
                    }

                    item.Estado     = ddestado.SelectedValue;
                    item.HoraInicio = txthorainicio.Text;
                    item.HoraFin    = txthorafin.Text;
                    lista.Add(item);
                }


                AtencionPeluqueriaBuss.GrabarHojaServicio(hoja, lista, 2);
                ListarHojas();
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal('hide');", true);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal2", "callbusqueda();", true);
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Mensaje", "$.growl.warning({ title: 'Mensaje Sistema', message: 'Error interno del sistema.'});", true);
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), "myModal", "$('#myModal').modal('hide');", true);
                //this.lblmsg.Text = ex.Message;
            }
        }
        //busqueda de hoja de servicio
        public static DataTable BusquedaHojaServicio(HojaServicio hoja)
        {
            string        conn = System.Configuration.ConfigurationManager.ConnectionStrings["database"].ToString();
            SqlConnection cnn  = new SqlConnection(conn);
            SqlCommand    cmd  = new SqlCommand();

            try
            {
                cnn.Open();
                cmd.CommandText = "usp_HojaServicio_gl";
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Connection  = cnn;

                if (hoja.NumHojaServicio != 0)
                {
                    cmd.Parameters.Add(new SqlParameter("@NumHoja", SqlDbType.Int)).Value = hoja.NumHojaServicio;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@NumHoja", SqlDbType.Int)).Value = DBNull.Value;
                }

                if (hoja.NombreCliente != String.Empty)
                {
                    cmd.Parameters.Add(new SqlParameter("@NombreCliente", SqlDbType.VarChar, 250)).Value = hoja.NombreCliente;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@NombreCliente", SqlDbType.VarChar, 250)).Value = DBNull.Value;
                }

                if (hoja.idServicio != 0)
                {
                    cmd.Parameters.Add(new SqlParameter("@idServicio", SqlDbType.Int)).Value = hoja.idServicio;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@idServicio", SqlDbType.Int)).Value = DBNull.Value;
                }


                if (hoja.FechaInicial != string.Empty)
                {
                    cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.Date)).Value = hoja.FechaInicial;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@FechaInicio", SqlDbType.Date)).Value = DBNull.Value;
                }

                if (hoja.FechaFinal != string.Empty)
                {
                    cmd.Parameters.Add(new SqlParameter("@FechaFin", SqlDbType.Date)).Value = hoja.FechaFinal;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@FechaFin", SqlDbType.Date)).Value = DBNull.Value;
                }

                if (hoja.idCliente != 0)
                {
                    cmd.Parameters.Add(new SqlParameter("@idCliente", SqlDbType.Int)).Value = hoja.idCliente;
                }
                else
                {
                    cmd.Parameters.Add(new SqlParameter("@idCliente", SqlDbType.Int)).Value = DBNull.Value;
                }

                SqlDataAdapter dap = new SqlDataAdapter(cmd);
                DataTable      dt  = new DataTable();

                dap.Fill(dt);

                return(dt);
            }
            catch (Exception ex)
            {
                throw;
            }
            finally
            {
                cnn.Close();
                cnn = null;
                cmd = null;
            }
        }