public IntroductionViewModel(GenericDataAccess<string> dataAccess)
        {
            this.dataAccess = dataAccess;
            introduction = dataAccess.TryLoad();

            SaveCommand = new RelayCommand<object>(_ => Save());
        }
Ejemplo n.º 2
0
        public IdentityViewModel(GenericDataAccess<Identity> dataAccess)
        {
            this.dataAccess = dataAccess;
            identity = dataAccess.TryLoad() ?? new Identity();

            if (identity.Picture != null)
                picture = Path.GetFullPath(dataAccess.GetFilePath(identity.Picture));

            SaveCommand = new RelayCommand<object>(_ => Save());
        }
Ejemplo n.º 3
0
        public async Task Remove_GivenNullEntity_EntityStateShouldNotBeUpdated()
        {
            using (var database = new DatabaseWrapper())
            {
                var dataAccess = new GenericDataAccess(database.WeeeContext);
                var competentAuthorityDataAccess = new CommonDataAccess(database.WeeeContext);
                var organisation = Organisation.CreateSoleTrader("Test Organisation");
                var aatf         = ObligatedWeeeIntegrationCommon.CreateAatf(database, organisation);

                database.WeeeContext.Aatfs.Add(ObligatedWeeeIntegrationCommon.CreateAatf(database, organisation));

                await database.WeeeContext.SaveChangesAsync();

                dataAccess.Remove <Aatf>(null);

                database.WeeeContext.ChangeTracker.Entries().Count(e => e.State == EntityState.Deleted).Should().Be(0);
            }
        }
Ejemplo n.º 4
0
 protected override void addParameters(int opcion)
 {
     GenericDataAccess.AddInParameter(this.comm, "?P_opcion", DbType.Int32, opcion);
     GenericDataAccess.AddInOutParameter(this.comm, "?P_id", DbType.Int32, this._oSalida_orden_carga.Id);
     GenericDataAccess.AddInParameter(this.comm, "?P_id_tipo_carga", DbType.Int32, this._oSalida_orden_carga.Id_tipo_carga);
     GenericDataAccess.AddInParameter(this.comm, "?P_id_usuario", DbType.Int32, this._oSalida_orden_carga.Id_usuario);
     GenericDataAccess.AddInParameter(this.comm, "?P_id_salida_trafico", DbType.Int32, this._oSalida_orden_carga.Id_salida_trafico);
     GenericDataAccess.AddInParameter(this.comm, "?P_folio_orden_carga", DbType.String, this._oSalida_orden_carga.Folio_orden_carga);
     GenericDataAccess.AddInParameter(this.comm, "?P_tiene_salida", DbType.Boolean, this._oSalida_orden_carga.Tiene_salida);
     if (this._oSalida_orden_carga.Observaciones_tranpsorte.Length == 0)
     {
         GenericDataAccess.AddInParameter(this.comm, "?P_observaciones_tranpsorte", DbType.String, DBNull.Value);
     }
     else
     {
         GenericDataAccess.AddInParameter(this.comm, "?P_observaciones_tranpsorte", DbType.String, this._oSalida_orden_carga.Observaciones_tranpsorte);
     }
 }
Ejemplo n.º 5
0
        internal int execInserts()
        {
            int rowInserted = 0;

            try
            {
                if (this._sbQry.Length > 0)
                {
                    this.comm   = GenericDataAccess.CreateCommand(this._sbQry.ToString());
                    rowInserted = GenericDataAccess.ExecuteNonQuery(this.comm);
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(rowInserted);
        }
Ejemplo n.º 6
0
    // Create a new order from the shopping cart
    public static string CreateOrder()
    {
        // get a configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "CreateOrder";
        // create a new parameter
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@CartID";
        param.Value         = shoppingCartId;
        param.DbType        = DbType.String;
        param.Size          = 36;
        comm.Parameters.Add(param);
        // return the result table
        return(GenericDataAccess.ExecuteScalar(comm));
    }
        /// <summary>
        /// Add constrain in roles when request action
        /// </summary>
        /// <param name="action"> Enum of actions</param>
        /// <param name="roles"> string of one or more role seperated by ',' </param>
        /// <param name="ConstrainsExpression"></param>
        public void AddActionDataConstrains(Actions action, string roles, Expression <Func <T, bool> > ConstrainsExpression)
        {
            if (AuthorizRole == null)
            {
                AuthorizRole = new GenericAuthorizRoles <T>();
            }

            if (AuthorizRole.DataAccess == null)
            {
                AuthorizRole.DataAccess = new List <GenericDataAccess <T> >();
            }
            GenericDataAccess <T> dataAccessRole = new GenericDataAccess <T>()
            {
                Action = action, Roles = roles, ExpressionFunc = ConstrainsExpression
            };

            AuthorizRole.DataAccess.Add(dataAccessRole);
        }
Ejemplo n.º 8
0
    public static DataTable GetRules(int PageIndex, int PageSize, string OrderBy, out int TotalCount)
    {
        GenericDataAccess gda = new GenericDataAccess();

        DbCommand comm = gda.CreateCommand();

        comm.CommandText = "GetRulesList";

        //parameter is not implemented

        DbParameter param1 = comm.CreateParameter();

        param1.ParameterName = "@PageIndex";
        param1.Value         = PageIndex;
        param1.DbType        = DbType.Int32;
        comm.Parameters.Add(param1);

        DbParameter param2 = comm.CreateParameter();

        param2.ParameterName = "@PageSize";
        param2.Value         = PageSize;
        param2.DbType        = DbType.Int32;
        comm.Parameters.Add(param2);

        DbParameter param3 = comm.CreateParameter();

        param3.ParameterName = "@OrderBy";
        param3.Value         = OrderBy;
        param3.DbType        = DbType.String;
        comm.Parameters.Add(param3);

        DbParameter param7 = comm.CreateParameter();

        param7.ParameterName = "@TotalCount";
        param7.Direction     = ParameterDirection.Output;
        param7.DbType        = DbType.Int32;
        comm.Parameters.Add(param7);

        // return the result table
        DataTable table = gda.ExecuteSelectCommand(comm);

        TotalCount = Convert.ToInt32(comm.Parameters["@TotalCount"].Value);
        return(table);
    }
Ejemplo n.º 9
0
        public int LikePost(int postID, int userID, string status)
        {
            GenericDataAccess <LIKE>         dataAccessLike         = new GenericDataAccess <LIKE>();
            GenericDataAccess <NOTIFICATION> dataAccessNotification = new GenericDataAccess <NOTIFICATION>();
            int result;
            int posterID = postDataAccess.GetProfileOwnerID(postID);

            var like = new LIKE()
            {
                LIKED_BY = userID,
                POST_ID  = postID
            };

            if (status == "like")
            {
                result = dataAccessLike.Create(like);

                if (result == 1 && userID != posterID)
                {
                    NOTIFICATION notification = new NOTIFICATION()
                    {
                        NOTIF_TYPE   = "L",
                        POST_ID      = postID,
                        RECEIVER_ID  = posterID,
                        SENDER_ID    = userID,
                        CREATED_DATE = DateTime.Now,
                        SEEN         = "N"
                    };

                    dataAccessNotification.Create(notification);
                }
            }
            else
            {
                result = dataAccessLike.Delete(likeDataAccess.GetLike(like));

                if (result == 1 && userID != posterID)
                {
                    dataAccessNotification.Delete(notificationDataAccess.GetNotificationForLike(like));
                }
            }

            return(result);
        }
Ejemplo n.º 10
0
    // Create a new Category
    public static bool CreateCategory(string departmentId,
                                      string name, string description)
    {
        // get a configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "CatalogCreateCategory";
        // create a new parameter
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@DepartmentID";
        param.Value         = departmentId;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // create a new parameter
        param = comm.CreateParameter();
        param.ParameterName = "@CategoryName";
        param.Value         = name;
        param.DbType        = DbType.String;
        param.Size          = 50;
        comm.Parameters.Add(param);
        // create a new parameter
        param = comm.CreateParameter();
        param.ParameterName = "@CategoryDescription";
        param.Value         = description;
        param.DbType        = DbType.String;
        param.Size          = 1000;
        comm.Parameters.Add(param);
        // result will represent the number of changed rows
        int result = -1;

        try
        {
            // execute the stored procedure
            result = GenericDataAccess.ExecuteNonQuery(comm);
        }
        catch
        {
            // any errors are logged in GenericDataAccess, we ignore them here
        }
        // result will be 1 in case of success
        return(result != -1);
    }
Ejemplo n.º 11
0
    public static DataTable GetValuationAdmin(string uvtid, int year, int month, string mileage, string ValuationType)
    {
        // get a configured DbCommand object
        GenericDataAccess gda = new GenericDataAccess();

        DbCommand comm = gda.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "valuation_process_admin";

        DbParameter param2 = comm.CreateParameter();

        param2.ParameterName = "@UVTID";
        param2.Value         = uvtid;
        param2.DbType        = DbType.String;
        comm.Parameters.Add(param2);

        param2 = comm.CreateParameter();
        param2.ParameterName = "@ValuationType";
        param2.Value         = ValuationType;
        param2.DbType        = DbType.String;
        comm.Parameters.Add(param2);

        param2 = comm.CreateParameter();
        param2.ParameterName = "@Year";
        param2.Value         = year;
        param2.DbType        = DbType.Int32;
        comm.Parameters.Add(param2);

        param2 = comm.CreateParameter();
        param2.ParameterName = "@Month";
        param2.Value         = month;
        param2.DbType        = DbType.Int32;
        comm.Parameters.Add(param2);

        param2 = comm.CreateParameter();
        param2.ParameterName = "@Mileage";
        param2.Value         = mileage;
        param2.DbType        = DbType.String;
        comm.Parameters.Add(param2);

        // return the result table
        return(gda.ExecuteSelectCommand(comm));
    }
Ejemplo n.º 12
0
 internal void fillLstDistinctBy()
 {
     try
     {
         this.comm = GenericDataAccess.CreateCommandSP("sp_Tarima_almacen");
         addParameters(10);
         this.dt   = GenericDataAccess.ExecuteSelectCommand(comm);
         this._lst = new List <Tarima_almacen>();
         foreach (DataRow dr in dt.Rows)
         {
             Tarima_almacen o = new Tarima_almacen();
             BindByDataRow(dr, o);
             if (dr["tarimas"] != DBNull.Value)
             {
                 int.TryParse(dr["tarimas"].ToString(), out entero);
                 o.Tarimas = entero;
                 entero    = 0;
             }
             if (dr["tarRem"] != DBNull.Value)
             {
                 int.TryParse(dr["tarRem"].ToString(), out entero);
                 o.TarRem = entero;
                 entero   = 0;
             }
             if (dr["btoRem"] != DBNull.Value)
             {
                 int.TryParse(dr["btoRem"].ToString(), out entero);
                 o.BtoRem = entero;
                 entero   = 0;
             }
             if (dr["pzaRem"] != DBNull.Value)
             {
                 int.TryParse(dr["pzaRem"].ToString(), out entero);
                 o.PzaRem = entero;
                 entero   = 0;
             }
             this._lst.Add(o);
         }
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 13
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    GenericDataAccess <Customer> customers = new GenericDataAccess <Customer>(new DataContext());
                    Customer customer = new Customer()
                    {
                        city      = model.city,
                        state     = model.state,
                        street    = model.street,
                        firstName = model.firstName,
                        lastName  = model.lastName,
                        zipCode   = model.zipCode,
                        Email     = model.Email,
                        userID    = user.Id,
                    };

                    customers.Insert(customer);
                    customers.Commit();


                    await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false);

                    // For more information on how to enable account confirmation and password reset please visit http://go.microsoft.com/fwlink/?LinkID=320771
                    // Send an email with this link
                    // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);
                    // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>");

                    return(RedirectToAction("Index", "Home"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Ejemplo n.º 14
0
        public static void usuarioUdt(Usuario oU)
        {
            IDbTransaction trans = null;

            try
            {
                trans = GenericDataAccess.BeginTransaction();
                UsuarioMng oUMng = new UsuarioMng();
                oUMng.O_Usuario = oU;
                oUMng.udt(trans);

                Usuario_bodega oUB = new Usuario_bodega()
                {
                    Id_usuario = oU.Id
                };
                Usuario_bodegaMng OUBMng = new Usuario_bodegaMng()
                {
                    O_Usuario_bodega = oUB
                };
                OUBMng.deleteByUsuario(trans);

                foreach (Usuario_bodega itemUB in oU.PLstUsuarioBodega)
                {
                    OUBMng = new Usuario_bodegaMng()
                    {
                        O_Usuario_bodega = new Usuario_bodega()
                        {
                            Id_usuario = itemUB.Id_usuario, Id_bodega = itemUB.Id_bodega
                        }
                    };
                    OUBMng.add(trans);
                }

                GenericDataAccess.CommitTransaction(trans);
            }
            catch
            {
                if (trans != null)
                {
                    GenericDataAccess.RollbackTransaction(trans);
                }
                throw;
            }
        }
Ejemplo n.º 15
0
        public static List <rptPartNom> PartNom(int anio_ini, int dia_ini, int anio_fin, int dia_fin)
        {
            List <rptPartNom> lst = new List <rptPartNom>();

            try
            {
                IDbCommand comm = GenericDataAccess.CreateCommandSP("sp_ZPartNom");

                //if (anio_ini == 1)
                //{
                //    GenericDataAccess.AddInParameter(comm, "?P_anio_ini", DbType.Int32, DBNull.Value);
                //    GenericDataAccess.AddInParameter(comm, "?P_dia_ini", DbType.Int32, DBNull.Value);
                //    GenericDataAccess.AddInParameter(comm, "?P_anio_fin", DbType.Int32, DBNull.Value);
                //    GenericDataAccess.AddInParameter(comm, "?P_dia_fin", DbType.Int32, DBNull.Value);
                //}
                //else
                //{
                //    GenericDataAccess.AddInParameter(comm, "?P_anio_ini", DbType.Int32, anio_ini);
                //    GenericDataAccess.AddInParameter(comm, "?P_dia_ini", DbType.Int32, dia_ini);
                //    GenericDataAccess.AddInParameter(comm, "?P_anio_fin", DbType.Int32, anio_fin);
                //    GenericDataAccess.AddInParameter(comm, "?P_dia_fin", DbType.Int32, dia_fin);
                //}
                DataTable dt = GenericDataAccess.ExecuteSelectCommand(comm);
                foreach (DataRow dr in dt.Rows)
                {
                    rptPartNom o = new rptPartNom()
                    {
                        Fecha       = Convert.ToDateTime(dr["fecha"]),
                        Bodega      = dr["bodega"].ToString(),
                        Cuenta      = dr["cuenta"].ToString(),
                        Cliente     = dr["cliente"].ToString(),
                        Ref_entrada = dr["ref_entrada"].ToString(),
                        Pza_tot     = Convert.ToInt32(dr["pza_tot"]),
                        Nom         = Convert.ToInt32(dr["nom"]),
                    };
                    lst.Add(o);
                }
            }
            catch
            {
                throw;
            }
            return(lst);
        }
        public List <ItemStock> GetAllStockItem(string companyId, string stockItemName)
        {
            DbCommand        comm       = null;
            List <ItemStock> stockItems = new List <ItemStock>();

            try
            {
                comm             = GenericDataAccess.CreateCommand();
                comm.CommandType = CommandType.Text;
                string sql = @"SELECT itm.CompanyId, itm.ItemId, itm.ItemName, itm.CountPerBox, itms.StockId, itms.TotalStock, itms.DamagedStock, itms.ChalanNo, itms.StockEntryDate
                                    FROM IM_Items itm LEFT JOIN IM_Items_Stock itms 
                                    ON itm.ItemId = itms.ItemId 
                                    WHERE CompanyId = @CompanyId";

                if (!string.IsNullOrEmpty(stockItemName))
                {
                    sql += " AND ItemName LIKE @ItemName";
                    CreateParameter.AddParam(comm, "@ItemName", stockItemName + "%", DbType.String);
                }

                string orderBySQL = "ORDER BY ItemName";
                comm.CommandText = string.Format("{0} {1}", sql, orderBySQL);

                CreateParameter.AddParam(comm, "@CompanyId", companyId, DbType.String);

                DbDataReader dr = GenericDataAccess.ExecuteQuery(comm);
                while (dr.Read())
                {
                    stockItems.Add(MapStockItem(dr));
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (comm != null && comm.Connection.State != ConnectionState.Closed)
                {
                    comm.Connection.Close();
                }
            }

            return(stockItems);
        }
Ejemplo n.º 17
0
        public Degrees GetDegrees(string cityId)
        {
            int result = 0;

            if (int.TryParse(cityId, out result))
            {
                return(GenericDataAccess.ExeciteSelect("test.GetCityDegrees",
                                                       new string[] { "id" },
                                                       new object[] { result })?
                       .Select(r => new Degrees {
                    Day = (int)r["degrees_day"], Night = (int)r["degrees_night"]
                })
                       .FirstOrDefault() ?? null);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 18
0
        public static void asnAdd(Asn o)
        {
            IDbTransaction tran = null;
            AsnMng         oMng = new AsnMng()
            {
                O_Asn = o
            };
            Asn_partidaMng          oAPMng  = new Asn_partidaMng();
            Asn_transporte_selloMng oATSMng = new Asn_transporte_selloMng();

            try
            {
                tran = GenericDataAccess.BeginTransaction();

                string folio = CatalogoCtrl.getFolio(enumTipo.ASN, tran);
                o.Folio = folio;
                oMng.add(tran);

                foreach (Asn_partida item in o.PLstPartida)
                {
                    item.Id_asn          = o.Id;
                    oAPMng.O_Asn_partida = item;
                    oAPMng.add(tran);
                }

                foreach (Asn_transporte_sello itemSello in o.PLstTranSello)
                {
                    itemSello.Id_asn = o.Id;
                    oATSMng.O_Asn_transporte_sellos = itemSello;
                    oATSMng.add(tran);
                }

                GenericDataAccess.CommitTransaction(tran);
            }
            catch
            {
                if (tran != null)
                {
                    GenericDataAccess.RollbackTransaction(tran);
                }
                throw;
            }
        }
Ejemplo n.º 19
0
        private DataTable getData(int anio, int mes)
        {
            DataTable dt = new DataTable();

            try
            {
                IDbCommand comm = GenericDataAccess.CreateCommandSP("sp_ZResAlm");

                GenericDataAccess.AddInParameter(comm, "?P_anio", DbType.Int32, anio);
                GenericDataAccess.AddInParameter(comm, "?P_mes", DbType.Int32, mes);

                dt = GenericDataAccess.ExecuteSelectCommand(comm);
            }
            catch
            {
                throw;
            }
            return(dt);
        }
Ejemplo n.º 20
0
    // Retrieve the list of products on catalog promotion
    public static DataTable GetProductsOnFrontPromo(string pageNumber, out int howManyPages)
    {
        // get a configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "CatalogGetProductsOnFrontPromo";
        // create a new parameter
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@DescriptionLength";
        param.Value         = BalloonShopConfiguration.ProductDescriptionLength;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // create a new parameter
        param = comm.CreateParameter();
        param.ParameterName = "@PageNumber";
        param.Value         = pageNumber;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // create a new parameter
        param = comm.CreateParameter();
        param.ParameterName = "@ProductsPerPage";
        param.Value         = BalloonShopConfiguration.ProductsPerPage;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // create a new parameter
        param = comm.CreateParameter();
        param.ParameterName = "@HowManyProducts";
        param.Direction     = ParameterDirection.Output;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);

        // execute the stored procedure and save the results in a DataTable
        DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);
        // calculate how many pages of products and set the out parameter
        int howManyProducts = Int32.Parse(comm.Parameters
                                          ["@HowManyProducts"].Value.ToString());

        howManyPages = (int)Math.Ceiling((double)howManyProducts / (double)BalloonShopConfiguration.ProductsPerPage);
        // return the page of products
        return(table);
    }
Ejemplo n.º 21
0
    public static DataTable GetPagingInfo(int PageIndex, int PageSize, string OrderBy, out int TotalCount)
    {
        // get a configured DbCommand object
        GenericDataAccess gda = new GenericDataAccess();

        DbCommand comm = gda.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "GetPagingInfo";

        DbParameter param2 = comm.CreateParameter();

        param2.ParameterName = "@PageIndex";
        param2.Value         = PageIndex;
        param2.DbType        = DbType.Int32;
        comm.Parameters.Add(param2);

        DbParameter param3 = comm.CreateParameter();

        param3.ParameterName = "@PageSize";
        param3.Value         = PageSize;
        param3.DbType        = DbType.Int32;
        comm.Parameters.Add(param3);

        DbParameter param1 = comm.CreateParameter();

        param1.ParameterName = "@OrderBy";
        param1.Value         = OrderBy;
        param1.DbType        = DbType.String;
        comm.Parameters.Add(param1);

        DbParameter param4 = comm.CreateParameter();

        param4.ParameterName = "@TotalCount";
        param4.Direction     = ParameterDirection.Output;
        param4.DbType        = DbType.Int32;
        comm.Parameters.Add(param4);

        DataTable table = gda.ExecuteSelectCommand(comm);

        TotalCount = Convert.ToInt32(comm.Parameters["@TotalCount"].Value);
        return(table);
    }
Ejemplo n.º 22
0
 public void countCatalog()
 {
     try
     {
         this.comm = GenericDataAccess.CreateCommandSP("sp_Cliente_grupo");
         addParameters(5);
         this.dt = GenericDataAccess.ExecuteSelectCommand(comm);
         if (dt.Rows.Count == 1)
         {
             DataRow dr = dt.Rows[0];
             if (dr["comprador"] != DBNull.Value)
             {
                 int.TryParse(dr["comprador"].ToString(), out entero);
                 this._oCliente_grupo.cantComprador = entero;
                 entero = 0;
             }
             if (dr["vendor"] != DBNull.Value)
             {
                 int.TryParse(dr["vendor"].ToString(), out entero);
                 this._oCliente_grupo.cantVendor = entero;
                 entero = 0;
             }
             if (dr["mercancia"] != DBNull.Value)
             {
                 int.TryParse(dr["mercancia"].ToString(), out entero);
                 this._oCliente_grupo.cantMercancia = entero;
                 entero = 0;
             }
         }
         else if (dt.Rows.Count > 1)
         {
             throw new Exception("Error de integridad");
         }
         else
         {
             throw new Exception("No existe información para el registro solicitado");
         }
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 23
0
    // retrieve the list of products in a category
    public static DataTable GetAllProductsInCategory(string categoryId)
    {
        // get a configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "CatalogGetAllProductsInCategory";
        // create a new parameter
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@CategoryID";
        param.Value         = categoryId;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // execute the stored procedure and save the results in a DataTable
        DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);

        return(table);
    }
Ejemplo n.º 24
0
    public static bool InsertDeviceList(string DeviceName, string DeviceModel, string ImagePath)
    {
        // get a configured DbCommand object
        GenericDataAccess gda = new GenericDataAccess();

        DbCommand comm = gda.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "InsertDeviceList";

        // create a new parameter
        DbParameter param1 = comm.CreateParameter();

        param1.ParameterName = "@DeviceName";
        param1.Value         = DeviceName;
        param1.DbType        = DbType.String;
        comm.Parameters.Add(param1);

        DbParameter param2 = comm.CreateParameter();

        param2.ParameterName = "@DeviceModel";
        param2.Value         = DeviceModel;
        param2.DbType        = DbType.String;
        comm.Parameters.Add(param2);

        DbParameter param3 = comm.CreateParameter();

        param3.ParameterName = "@pic";
        param3.Value         = ImagePath;
        param3.DbType        = DbType.String;
        comm.Parameters.Add(param3);


        // return the result table
        if (gda.ExecuteNonQuery(comm) > 0)
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 25
0
        public static void Cliente_udt(Cliente oC)
        {
            IDbTransaction trans = null;

            try
            {
                trans = GenericDataAccess.BeginTransaction();
                ClienteMng oCMng = new ClienteMng();
                oCMng.O_Cliente = oC;
                oCMng.udt(trans);

                Cliente_documentoMng oCDMng = new Cliente_documentoMng();
                Cliente_documento    oCDDlt = new Cliente_documento();
                oCDDlt.Id_cliente          = oC.Id;
                oCDMng.O_Cliente_documento = oCDDlt;
                oCDMng.dltByCliente(trans);

                foreach (Cliente_documento oCD in oC.PLstDocReq)
                {
                    oCD.Id_cliente             = oC.Id;
                    oCDMng.O_Cliente_documento = oCD;
                    oCDMng.add(trans);
                }

                Cliente_copia_operacionMng oCCOpMng = new Cliente_copia_operacionMng();
                oCCOpMng.dltByCliente(oC.Id, trans);
                foreach (Cliente_copia_operacion oCCOp in oC.PLstCopiaOp)
                {
                    oCCOp.Id_cliente = oC.Id;
                    oCCOpMng.O_Cliente_copia_operacion = oCCOp;
                    oCCOpMng.add(trans);
                }
                GenericDataAccess.CommitTransaction(trans);
            }
            catch
            {
                if (trans != null)
                {
                    GenericDataAccess.RollbackTransaction(trans);
                }
                throw;
            }
        }
 internal void getAvailable(IDbTransaction trans)
 {
     try
     {
         this._oCliente_codigo_cancelado.Codigo = string.Empty;
         this.comm = GenericDataAccess.CreateCommandSP("sp_Cliente_codigo_cancelado");
         addParameters(5);
         this.dt = GenericDataAccess.ExecuteSelectCommand(comm);
         if (dt.Rows.Count == 1)
         {
             DataRow dr = dt.Rows[0];
             this._oCliente_codigo_cancelado.Codigo = dr["codigo"].ToString();
         }
     }
     catch
     {
         throw;
     }
 }
Ejemplo n.º 27
0
        public static List <CommerceLibOrderInfo> GetOrdersByStatus(
            int status)
        {
            // get a configured DbCommand object
            DbCommand comm = GenericDataAccess.CreateCommand();

            // set the stored procedure name
            comm.CommandText = "CommerceLibOrdersGetByStatus";
            // create a new parameter
            DbParameter param = comm.CreateParameter();

            param.ParameterName = "@Status";
            param.Value         = status;
            param.DbType        = DbType.Int32;
            comm.Parameters.Add(param);
            // obtain the results
            return(ConvertDataTableToOrders(
                       GenericDataAccess.ExecuteSelectCommand(comm)));
        }
Ejemplo n.º 28
0
        public ActionResult UploadPhoto(string username, HttpPostedFileBase file)
        {
            USER user = new USER();

            user = userDataAccess.GetUser(null, username);

            if (file.ContentLength > 0 && file.ContentLength < 2097152)
            {
                if (file.ContentType == "image/jpg" || file.ContentType == "image/jpeg" || file.ContentType == "image/png")
                {
                    user.PROFILE_PIC = new byte[file.ContentLength];
                    file.InputStream.Read(user.PROFILE_PIC, 0, file.ContentLength);
                    GenericDataAccess <USER> dataAccessUser = new GenericDataAccess <USER>();
                    dataAccessUser.Update(user);
                }
            }

            return(RedirectToAction("UserProfile", "Pastebook", new { username = username }));
        }
Ejemplo n.º 29
0
    // Retrieve the order details (the products that are part of that order)
    public static DataTable GetDetails(string orderID)
    {
        // get a configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "OrderGetDetails";
        // create a new parameter
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@OrderId";
        param.Value         = orderID;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // return the results
        DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);

        return(table);
    }
Ejemplo n.º 30
0
        public void fillLstTarifaByServicio(int id_cliente, int id_servicio)
        {
            try
            {
                this.comm = GenericDataAccess.CreateCommand(
                    "select ms.id, cm.sku, cm.nombre, ms.precio " +
                    "from cliente_mercancia cm " +
                    "join mercancia_servicio ms on " +
                    "   cm.id = ms.id_cliente_mercancia " +
                    "   and cm.id_cliente = ?id_cliente " +
                    "   and ms.id_servicio = ?id_servicio ");

                GenericDataAccess.AddInParameter(this.comm, "?id_cliente", DbType.Int32, id_cliente);
                GenericDataAccess.AddInParameter(this.comm, "?id_servicio", DbType.Int32, id_servicio);

                this.dt = GenericDataAccess.ExecuteSelectCommand(this.comm);
                var qry =
                    from result in this.dt.AsEnumerable()
                    select new
                {
                    id     = result.Field <Int32>("id"),
                    sku    = result.Field <string>("sku"),
                    nombre = result.Field <string>("nombre"),
                    precio = result.Field <decimal>("precio")
                };

                foreach (var item in qry)
                {
                    Cliente_mercancia o = new Cliente_mercancia()
                    {
                        Id     = item.id,
                        Sku    = item.sku,
                        Nombre = item.nombre,
                        Tarifa = item.precio
                    };
                    this._lst.Add(o);
                }
            }
            catch
            {
                throw;
            }
        }
Ejemplo n.º 31
0
    // move product to a new category
    public static bool MoveProductToCategory(string productId, string oldCategoryId,
                                             string newCategoryId)
    {
        // get a configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "CatalogMoveProductToCategory";
        // create a new parameter
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@ProductID";

        param.Value  = productId;
        param.DbType = DbType.Int32;
        comm.Parameters.Add(param);
        // create a new parameter
        param = comm.CreateParameter();
        param.ParameterName = "@OldCategoryID";
        param.Value         = oldCategoryId;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // create a new parameter
        param = comm.CreateParameter();
        param.ParameterName = "@NewCategoryID";
        param.Value         = newCategoryId;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // result will represent the number of changed rows
        int result = -1;

        try
        {
            // execute the stored procedure
            result = GenericDataAccess.ExecuteNonQuery(comm);
        }
        catch
        {
            // any errors are logged in GenericDataAccess, we ignore them here
        }
        // result will be 1 in case of success
        return(result != -1);
    }
Ejemplo n.º 32
0
    // Retrieve the recent orders
    public static DataTable GetByRecent(int count)
    {
        // get a configured DbCommand object
        DbCommand comm = GenericDataAccess.CreateCommand();

        // set the stored procedure name
        comm.CommandText = "OrdersGetByRecent";
        // create a new parameter
        DbParameter param = comm.CreateParameter();

        param.ParameterName = "@Count";
        param.Value         = count;
        param.DbType        = DbType.Int32;
        comm.Parameters.Add(param);
        // return the result table
        DataTable table = GenericDataAccess.ExecuteSelectCommand(comm);

        return(table);
    }