Ejemplo n.º 1
0
        private void doAction()
        {
            using (var ctx = new TicketsEntities())
            {
                int tech_num = Convert.ToInt16(textBox_techCode.Text);
                //output paramenter
                ObjectParameter objParam = new ObjectParameter("cod", typeof(String));

                ctx.proc_Assign_Technician(tech_num, objParam);
                String ticket_code = Convert.ToString(objParam.Value);
                if (ticket_code.Equals("."))
                {
                    MessageBox.Show("The Technician with number " + tech_num + " doesn't exist in the DB");
                }
                else
                {
                    if (ticket_code.Equals(""))
                    {
                        MessageBox.Show("There are no unassigned Tickets.");
                    }
                    else
                    {
                        MessageBox.Show("The Technician with number " + tech_num + " has been assigned to Ticket " + ticket_code);
                    }
                }
                //
                ctx.SaveChanges();
            }
        }
 private void GetTickets()
 {
     using (var ctx = new TicketsEntities())
     {
         var query = from t in ctx.vi_Ticket
                     where t.ticketState != "closed"
                     select t;
         //
         foreach (var ticket in query)
         {
             dgv_tickets.Rows.Add(
                 ticket.cod,
                 ticket.ticketState,
                 ticket.ticketDescription,
                 ticket.ticketPriority,
                 ticket.ticketType,
                 ticket.ticketUser,
                 ticket.creationDate,
                 ticket.technician,
                 ticket.closeDate
                 );
         }
         ctx.SaveChanges();
     }
 }
        private void GetTicketInfo()
        {
            using (var ctx = new TicketsEntities())
            {
                bool   reveal      = true;
                String ticket_code = textBox_ticketCode.Text;
                //
                // get ticket steps
                //
                var result = ctx.proc_Get_Ticket_Steps(ticket_code);
                var q      = result.ToList();

                //

                if (q.Count() == 0)
                {
                    //if ticket code doesn't exist, hides the insertion section
                    Conceal();
                    dgv_steps.Rows.Clear();
                    MessageBox.Show("There isn't any ticket with the code " + ticket_code);
                }
                else
                {
                    foreach (var line in q)
                    {
                        if (!line.ticketState.Equals("In Progress"))
                        {
                            dgv_steps.Rows.Clear();
                            MessageBox.Show("The ticket " + ticket_code + " is not in progress");
                            Conceal();
                            reveal = false;
                            break;
                        }
                        dgv_steps.Rows.Add(
                            line.orderNumber,
                            line.description
                            );
                        //stores the responsible technician for the ticket, for future use
                        resp_technician = Convert.ToInt32(line.technician);
                        //stores the ticket's ticket type for future use
                        ticket_type = line.ticketType;
                    }
                    if (reveal)
                    {
                        Reveal();
                    }
                }
                //
                ctx.SaveChanges();
            }
        }
Ejemplo n.º 4
0
        public async Task <bool> InsertAddSubCategoriaHistorial(Guid IdUsuario, Guid IdSubCategoria)
        {
            bool validate = false;

            using (var db = new TicketsEntities())
            {
                var result = db.spInsHistorialUsuario(IdUsuario, IdSubCategoria);
                if (result < 0)
                {
                    validate = true;
                }
            }

            return(validate);
        }
Ejemplo n.º 5
0
        public async Task <bool> InsertCategoria(CategoriaViewModel cat)
        {
            bool validate = false;

            using (var db = new TicketsEntities())
            {
                var result = db.spInsCategoria(cat.IdCategoria, cat.Nombre, cat.Descripcion, cat.UrlImagen);
                if (result < 0)
                {
                    validate = true;
                }
            }

            return(validate);
        }
Ejemplo n.º 6
0
        public async Task <bool> InsertUsuario(UsuarioViewModel usuario)
        {
            bool validate = false;

            using (var db = new TicketsEntities())
            {
                var result = db.spInsertUsuario(usuario.Nombre, usuario.Apellidos, usuario.Sexo,
                                                usuario.Correo, usuario.Contrasena, usuario.TipoLogin, usuario.UrlImagen);
                if (result < 0)
                {
                    validate = true;
                }
            }

            return(validate);
        }
Ejemplo n.º 7
0
        public async Task <bool> InsertSubcategoria(SubCategoriaViewModel subcategoria)
        {
            bool validate = false;

            using (var db = new TicketsEntities())
            {
                var result = db.spInsSubCategoria(subcategoria.IdCategoria, subcategoria.Nombre,
                                                  subcategoria.Descripcion, subcategoria.UrlImagen, subcategoria.PrecioNormal,
                                                  subcategoria.PrecioDescuento, subcategoria.CodigoDescuento);
                if (result < 0)
                {
                    validate = true;
                }

                return(validate);
            }
        }
 private void DoInsertion()
 {
     using (var ctx = new TicketsEntities())
     {
         //
         // insert ticket action
         //
         String ticketCode      = textBox_ticketCode.Text;
         int    tech            = Convert.ToInt32(textBox_techNum.Text);
         String ticketType      = ticket_type;
         int    stepOrderNumber = Convert.ToInt32(textBox_stepNum.Text);
         String note            = textBox_actionNote.Text;
         //output paramenter
         ObjectParameter objParam = new ObjectParameter("orderNumber", typeof(int));
         ctx.sp_Insert_Ticket_Action(ticketCode, tech, ticketType, stepOrderNumber, note, objParam);
         //
         if (MessageBox.Show("When you press Ok, the action will be closed", "Confirm", MessageBoxButtons.OK) == DialogResult.OK)
         {
             //
             // end ticket action
             //
             ctx.sp_End_Ticket_Action(Convert.ToInt32(objParam.Value), ticketCode);
             //
             if (MessageBox.Show("Did the action solve the problem?", "Confirm", MessageBoxButtons.OKCancel) == DialogResult.OK)
             {
                 if (resp_technician == Convert.ToInt32(textBox_techNum.Text))
                 {
                     //
                     // close ticket
                     //
                     ctx.sp_Close_Ticket(ticketCode, tech);
                     MessageBox.Show("The ticket " + ticketCode + " has been closed.");
                 }
                 else
                 {
                     MessageBox.Show("You're not the technician responsible for this ticket, so it's not closed.");
                 }
                 dgv_steps.Rows.Clear();
             }
         }
         //
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 9
0
        public async Task <List <CategoriaViewModel> > GetCategorias()
        {
            var ListCategoria = new List <CategoriaViewModel>();

            using (var db = new TicketsEntities())
            {
                var result = db.spSelCategorias();
                foreach (var item in result)
                {
                    var categoria = new CategoriaViewModel();
                    categoria.Descripcion = item.Descripcion;
                    categoria.IdCategoria = item.IdCategoria;
                    categoria.Nombre      = item.Nombre;
                    categoria.UrlImagen   = item.UrlImagen;
                    ListCategoria.Add(categoria);
                }
            }

            return(ListCategoria);
        }
Ejemplo n.º 10
0
        public async Task <UsuarioViewModel> GetUsuario(string Correo, string password)
        {
            var usuario = new UsuarioViewModel();

            using (var db = new TicketsEntities())
            {
                var result = db.spSelUsuario(Correo, password);
                foreach (var item in result)
                {
                    usuario.Nombre     = item.Nombre;
                    usuario.Apellidos  = item.Apellidos;
                    usuario.Contrasena = item.Contrasena;
                    usuario.Correo     = item.Correo;
                    usuario.IdUsuario  = item.IdUsuario;
                    usuario.Sexo       = item.Sexo;
                    usuario.TipoLogin  = item.TipoLogin;
                    usuario.UrlImagen  = item.UrlImagen;
                }
            }

            return(usuario);
        }
Ejemplo n.º 11
0
 private void doAction()
 {
     using (var ctx = new TicketsEntities())
     {
         String ticketCode = textBox_cod.Text;
         //output paramenter
         ObjectParameter objParam = new ObjectParameter("res", typeof(int));
         ctx.proc_Remove_Ticket(ticketCode, objParam);
         // proc output that indicates success
         int r = Convert.ToInt32(objParam.Value);
         if (r == 0)
         {
             MessageBox.Show("The ticket with code " + ticketCode + "does not exist or has already been removed.");
         }
         else
         {
             MessageBox.Show("The ticket with code " + ticketCode + "has been removed");
         }
         //
         ctx.SaveChanges();
     }
 }
 //button export click event
 private void btn_export_Click(object sender, EventArgs e)
 {
     using (var ctx = new TicketsEntities())
     {
         DataSet ds = new DataSet();
         // get desired ticket
         String ticketCod = textBox_ticketCode.Text;
         //reads XML_Schema to build dataset
         ds.ReadXmlSchema("XML_Schema.xsd");
         DataTableCollection dtc = ds.Tables;
         //
         var result = ctx.proc_Get_Ticket_Info(ticketCod);
         //populate dataset
         int i = 0;
         foreach (var ticket in result)
         {
             if (i == 0)
             {
                 // ticket info
                 dtc["ticket"].Rows.Add(new Object[] { ticket.tt_id, ticket.cod, ticket.ticketState, ticket.ticketDescription, 1 });
                 dtc["owner"].Rows.Add(new Object[] { ticket.owner_email, ticket.owner_name, ticket.owner_id, ticket.owner_email, 1 });
                 dtc["supervisor"].Rows.Add(new Object[] { ticket.anumber, ticket.tech_name, ticket.tech_email, ticket.anumber, 1 });
                 dtc["type_type"].Rows.Add(new Object[] { ticket.tt_id, ticket.tt_name, ticket.tt_id, 1 });
                 // ticket actions sequence
                 dtc["actions"].Rows.Add(new object[] { 1 });
                 ++i;
             }
             // continues until there's no more actions
             dtc["action"].Rows.Add(new object[] { ticket.orderNumber, ticket.beginDate, ticket.endDate, ticket.orderNumber, 1 });
         }
         ds.DataSetName = "Ticket_Info";
         //saves both xsd and xml
         ds.WriteXml(textBox_filename.Text + ".xml");
         ds.WriteXmlSchema(textBox_filename.Text + ".xsd");
         MessageBox.Show("The ticket " + textBox_ticketCode.Text + " has been exported to " + textBox_filename + ".xml");
         //
         ctx.SaveChanges();
     }
 }
Ejemplo n.º 13
0
        public async Task <List <HistorialUsuarioViewModel> > GetHistorialUsuario(Guid IdUsuario)
        {
            var listhistorial = new List <HistorialUsuarioViewModel>();

            using (var db = new TicketsEntities())
            {
                var result = db.spSelHistorialUsuario(IdUsuario);
                foreach (var item in result)
                {
                    var historial = new HistorialUsuarioViewModel();
                    historial.IdSubCategoria  = item.IdSubCategoria;
                    historial.Nombre          = item.Nombre;
                    historial.Descripcion     = item.Descripcion;
                    historial.UrlImagen       = item.UrlImagen;
                    historial.PrecioNormal    = item.PrecioNormal;
                    historial.PrecioDescuento = item.PrecioDescuento;
                    historial.CodigoDescuento = item.CodigoDescuento;
                    listhistorial.Add(historial);
                }
            }

            return(listhistorial);
        }
Ejemplo n.º 14
0
        public async Task <List <SubCategoriaViewModel> > GetSubCategoria(Guid IdCategoria)
        {
            var ListSubcategoria = new List <SubCategoriaViewModel>();

            using (var db = new TicketsEntities())
            {
                var result = db.spSelSubCategorias(IdCategoria);
                foreach (var item in result)
                {
                    var subcategoria = new SubCategoriaViewModel();
                    subcategoria.Nombre          = item.Nombre;
                    subcategoria.CodigoDescuento = item.CodigoDescuento;
                    subcategoria.Descripcion     = item.Descripcion;
                    subcategoria.IdCategoria     = item.IdCategoria;
                    subcategoria.IdSubCategoria  = item.IdSubCategoria;
                    subcategoria.PrecioDescuento = item.PrecioDescuento;
                    subcategoria.PrecioNormal    = item.PrecioNormal;
                    subcategoria.UrlImagen       = item.UrlImagen;
                    ListSubcategoria.Add(subcategoria);
                }
            }

            return(ListSubcategoria);
        }