예제 #1
0
        }//fin del metodo

        public List <PaymentDetails> GetDetailValues(PaymentEnt paymentEnt)
        {
            //bool guardado = false; //bandera
            int x = 0; //variable de control



            foreach (PaymentDetails tpay in DetailInfo)
            {
                x = 0;
                tpay.Id_payment = getIdPayment(paymentEnt);
                sb.Append("INSERT INTO payment_details ");
                sb.Append("(id_payment,id_course_service)");
                sb.Append(" VALUES('" + tpay.Id_payment + "','" + tpay.Id_course_service + "');");


                Console.WriteLine(tpay.Id_course_service);
                try
                {
                    con.AbrirCOnexion();
                    x = con.Ejecutar(CommandType.Text, sb.ToString());

                    if (x > 0)
                    {
                        //guardado = true;
                        //var ms = new MessageDialog(null, DialogFlags.Modal,
                        //MessageType.Info, ButtonsType.Ok, "Se guardo el pago con exito!");
                        //ms.Run();
                        //ms.Destroy();
                    }
                }
                catch (Exception e)
                {
                    var ms = new MessageDialog(null, DialogFlags.Modal,
                                               MessageType.Error, ButtonsType.Ok, e.Message);
                    ms.Run();
                    ms.Destroy();
                    throw;
                }
                finally
                {
                    con.CerrarConexion();
                }
            }



            return(DetailInfo);
        }
예제 #2
0
        public bool SavePayment(PaymentEnt pay)
        {
            bool guardado = false; //bandera
            int  x        = 0;     //variable de control

            sb.Clear();
            sb.Append("INSERT INTO payment ");
            sb.Append("(id_costumer,date,total,iva,payment_method,subtotal)");
            sb.Append(" VALUES('" + pay.Id_costumer + "','" + pay.Date.ToString("yyyy-MM-dd HH:mm:ss") + "','" + pay.Total + "','" + pay.Iva + "','" + pay.Payment_method + "','" + pay.Subtotal + "');");

            try
            {
                con.AbrirCOnexion();
                x = con.Ejecutar(CommandType.Text, sb.ToString());

                if (x > 0)
                {
                    guardado = true;
                    var ms = new MessageDialog(null, DialogFlags.Modal,
                                               MessageType.Info, ButtonsType.Ok, "Se guardo el pago con exito!");
                    ms.Run();
                    ms.Destroy();
                }
                return(guardado);
            }
            catch (Exception e)
            {
                var ms = new MessageDialog(null, DialogFlags.Modal,
                                           MessageType.Error, ButtonsType.Ok, e.Message);
                ms.Run();
                ms.Destroy();
                throw;
            }
            finally
            {
                con.CerrarConexion();
            }
        }//fin del metodo
예제 #3
0
        public int getIdPayment(PaymentEnt paymentEnt)
        {
            int         id  = 0;
            IDataReader idr = null;

            sb.Clear();
            sb.Append("USE escuela_manejo;");
            sb.Append("SELECT id_payment FROM payment WHERE id_costumer =" + "'" + paymentEnt.Id_costumer + "' AND date ='" + paymentEnt.Date.ToString("yyyy-MM-dd HH:mm:ss") + "';");

            //Console.WriteLine(paymentEnt.Date.ToString("yyyy-MM-dd HH:mm:ss"));
            try
            {
                con.AbrirCOnexion();

                idr = con.Leer(CommandType.Text, sb.ToString());

                if (idr.Read())
                {
                    id = (Int32)idr[0];
                    Console.WriteLine(id);
                }

                idr.Close();
                return(id);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.WriteLine(e.StackTrace);
                throw;
            }
            finally
            {
                con.CerrarConexion();
            }
        }