Exemple #1
0
        /// <summary>
        ///     Metodo para ejcutar todos las ciudades por pais
        /// </summary>
        /// <exception cref="DatabaseException">
        ///     Lanzada si ocurre un fallo al ejecutar la funcion en la base de
        ///     datos
        /// </exception>
        public void Execute()
        {
            DAOFactory  factory     = DAOFactory.GetFactory(DAOFactory.Type.Postgres);
            LocationDAO locationDao = factory.GetLocationDAO();

            _location = locationDao.GetCitiesByCountry(_id);
        }
        private void LoadDataToCombobox()
        {
            DataSet   ds = new DataSet();
            DataTable dt = new DataTable();

            try
            {
                ds = LocationDAO.LoadDataCombobox();
                if (ds != null && ds.Tables.Count > 0)
                {
                    dt = ds.Tables[0].Copy();
                    cboLocation.Items.Add(new clsComboItem(-1, ""));
                    foreach (DataRow item in dt.Rows)
                    {
                        clsComboItem itemCbo = new clsComboItem();
                        itemCbo.Value   = item["Value"];
                        itemCbo.Display = item["Display"].ToString();
                        cboLocation.Items.Add(itemCbo);
                    }
                    cboLocation.SelectedIndex = dt.Rows.Count > 0 ? 0 : -1;
                    dt.Clear();
                }
                ds.Clear();
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
                dt.Dispose();
            }
        }
Exemple #3
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                if (string.IsNullOrWhiteSpace(txtID.Text))
                {
                    clsMessages.ShowInformation("Vui lòng chọn dòng dữ liệu muốn xóa!");
                    return;
                }
                long lID = Convert.ToInt64(txtID.Text);

                ds = LocationDAO.Location_Del(lID);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1)
                {
                    clsMessages.ShowInformation("Xóa thành công!");
                    LoadDataToForm();
                }
                else
                {
                    clsMessages.ShowWarning(ds.Tables[0].Rows[0]["ErrorDesc"].ToString());
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }
Exemple #4
0
        /// <summary>
        ///  map the dao to the entity
        /// </summary>
        /// <param name="ssdao"></param>
        /// <returns></returns>
        public Location MapToEntity(LocationDAO ldao)
        {
            Location l      = null;
            Location fromDB = null;
            //use automapper to map matching properties
            var mapper = LocationMapper.CreateMapper();

            if (ldao != null)
            {
                l = mapper.Map <Location>(ldao);

                //get original object from db
                if (!string.IsNullOrWhiteSpace(ldao.LocationName))
                {
                    fromDB = db.Location.Where(m => m.LocationName.Equals(ldao.LocationName)).FirstOrDefault();
                }
                //if db object exist then use existing object and map properties sent from dao
                if (fromDB != null)
                {
                    l = fromDB;
                    if (!string.IsNullOrWhiteSpace(ldao.LocationName))
                    {
                        l.LocationName = ldao.LocationName;
                    }
                }
                //if db object does not exist use automapper version of object and set active to true
                else
                {
                    l.IsActive = true;
                }
            }
            return(l);
        }
Exemple #5
0
        /// <summary>
        ///     Metodo para ejecutar el elimnar una ubicacion
        /// </summary>
        /// <exception cref="DatabaseException">
        ///     Lanzada si ocurre un fallo al ejecutar la funcion en la base de
        ///     datos
        /// </exception>
        public void Execute()
        {
            DAOFactory  factory     = DAOFactory.GetFactory(DAOFactory.Type.Postgres);
            LocationDAO locationDao = factory.GetLocationDAO();

            locationDao.DeleteLocation(_id);
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                LocationDTO obj = new LocationDTO();
                obj.ID         = -1;
                obj.City       = txtCity.Text;
                obj.District   = txtDistrict.Text;
                obj.Region     = txtRegion.Text;
                obj.StreetName = txtStreetName.Text;

                ds = LocationDAO.Location_InsUpd(obj);
                if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0]["Result"]) == 1)
                {
                    clsMessages.ShowInformation("Thêm thành công!");
                    frmParent.LoadDataToForm();
                    this.Close();
                }
                else
                {
                    clsMessages.ShowWarning("Thêm thất bại!");
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }
Exemple #7
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            DataSet ds = new DataSet();

            try
            {
                LocationDTO obj = new LocationDTO();
                obj.ID         = -1;
                obj.City       = txtCity.Text;
                obj.District   = txtDistrict.Text;
                obj.Region     = txtRegion.Text;
                obj.StreetName = txtStreetName.Text;

                ds = LocationDAO.Location_Search(obj);
                if (ds != null && ds.Tables.Count > 0)
                {
                    dgvLocation.DataSource = ds.Tables[0].Copy();
                }
                else
                {
                    clsMessages.ShowWarning("Không tìm thấy");
                }
            }
            catch (Exception ex)
            {
                clsMessages.ShowErrorException(ex);
            }
            finally
            {
                ds.Dispose();
            }
        }
        /// <summary>
        ///     Metodo para obtener todos los ubicaciones guardados.
        /// </summary>
        /// <exception cref="DatabaseException">
        ///     Lanzada si ocurre un fallo al ejecutar la funcion en la base de
        ///     datos
        /// </exception>
        public void Execute()
        {
            DAOFactory  factory     = DAOFactory.GetFactory(DAOFactory.Type.Postgres);
            LocationDAO locationDao = factory.GetLocationDAO();

            _location = locationDao.GetLocations();
        }
Exemple #9
0
        private void LoadWardInfor(int districtID)
        {
            List <DataConnect.Location> ward = new LocationDAO().ListLocationFromParent(districtID);

            cbbWard.DataSource    = ward;
            cbbWard.DisplayMember = "LocationName";
            cbbWard.ValueMember   = "LocationID";
        }
Exemple #10
0
        private void LoadDistrictInfor(int provinceID)
        {
            List <DataConnect.Location> district = new LocationDAO().ListLocationFromParent(provinceID);

            cbbDistrict.DataSource    = district;
            cbbDistrict.DisplayMember = "LocationName";
            cbbDistrict.ValueMember   = "LocationID";
        }
Exemple #11
0
        private void LoadProvinceInfor()
        {
            List <DataConnect.Location> province = new LocationDAO().ListAllProvince();

            cbbProvince.DataSource    = province;
            cbbProvince.DisplayMember = "LocationName";
            cbbProvince.ValueMember   = "LocationID";
            cbbProvince.SelectedIndex = 0;
        }
        public ActionResult Index()
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("../Login/Index"));
            }

            return(View(LocationDAO.FindAll()));
        }
Exemple #13
0
        /// <summary> Retrieves in this LocationCollection object all LocationEntity objects which are related via a  relation of type 'm:n' with the passed in ProductEntity.
        /// All current elements in the collection are removed from the collection.</summary>
        /// <param name="productInstance">ProductEntity object to be used as a filter in the m:n relation</param>
        /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param>
        /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
        /// <param name="pageNumber">The page number to retrieve.</param>
        /// <param name="pageSize">The page size of the page to retrieve.</param>
        /// <returns>true if the retrieval succeeded, false otherwise</returns>
        public virtual bool GetMultiManyToManyUsingProductCollectionViaProductInventory(IEntity productInstance, long maxNumberOfItemsToReturn, ISortExpression sortClauses, int pageNumber, int pageSize)
        {
            if (!base.SuppressClearInGetMulti)
            {
                this.Clear();
            }
            LocationDAO dao = DAOFactory.CreateLocationDAO();

            return(dao.GetMultiUsingProductCollectionViaProductInventory(base.Transaction, this, maxNumberOfItemsToReturn, sortClauses, base.EntityFactoryToUse, productInstance, pageNumber, pageSize));
        }
        public ActionResult Update(int Id)
        {
            if (Session["username"] == null)
            {
                return(RedirectToAction("../Login/Index"));
            }

            //retorna para a view o objeto a ser atualizado
            return(View("Insert", LocationDAO.FindById(Id)));
        }
        //thong tin chung
        public ActionResult CommonInfo()
        {
            var commonInfo = LocationDAO.GetCommonInfoByID("commoninfo");

            if (commonInfo == null)
            {
                commonInfo = new CommonBO();
            }
            return(View(commonInfo));
        }
Exemple #16
0
        /// <summary> Retrieves in this LocationCollection object all LocationEntity objects which are related via a  relation of type 'm:n' with the passed in WorkOrderEntity.
        /// All current elements in the collection are removed from the collection.</summary>
        /// <param name="workOrderInstance">WorkOrderEntity object to be used as a filter in the m:n relation</param>
        /// <param name="maxNumberOfItemsToReturn"> The maximum number of items to return with this retrieval query.</param>
        /// <param name="sortClauses">The order by specifications for the sorting of the resultset. When not specified, no sorting is applied.</param>
        /// <param name="prefetchPathToUse">the PrefetchPath which defines the graph of objects to fetch.</param>
        /// <returns>true if the retrieval succeeded, false otherwise</returns>
        public bool GetMultiManyToManyUsingWorkOrderCollectionViaWorkOrderRouting(IEntity workOrderInstance, long maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath prefetchPathToUse)
        {
            if (!base.SuppressClearInGetMulti)
            {
                this.Clear();
            }
            LocationDAO dao = DAOFactory.CreateLocationDAO();

            return(dao.GetMultiUsingWorkOrderCollectionViaWorkOrderRouting(base.Transaction, this, maxNumberOfItemsToReturn, sortClauses, base.EntityFactoryToUse, workOrderInstance, prefetchPathToUse));
        }
Exemple #17
0
        internal static Location GetOrderLocation(Order o)
        {
            Location Location;

            using (var DB = new P0Context())
            {
                LocationDAO.LoadLocationsList(DB);
                Location = DB.LocationList.First(l => l.LocationID == o.LocationID);
            }
            return(Location);
        }
Exemple #18
0
        internal static List <Location> GetAllLocations()
        {
            List <Location> LocationList;

            using (var DB = new P0Context())
            {
                LocationDAO.LoadLocationsList(DB);
                LocationList = DB.LocationList;
            }
            return(LocationList);
        }
 public string Post(JsonLocation jsonLocation)
 {
     try
     {
         LocationDAO.InitializeInsertLocation(jsonLocation);
     }
     catch (Exception ex)
     {
     }
     return("Location");
 }
Exemple #20
0
 private void InsertToDBButton_Click(object sender, EventArgs e)
 {
     if (LocationDAO.InsertMany(reader.GetLocations()))
     {
         MessageBox.Show("Entries added to the DB.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
     }
     else
     {
         MessageBox.Show("Error accessing DB", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Exemple #21
0
        public int addLocation(string nombre, string direccion, string encargado, string companyId)
        {
            Local l = new Local()
            {
                Nombre    = nombre,
                Direccion = direccion,
                Encargado = encargado,
                Id_Em     = Convert.ToInt32(companyId)
            };

            return(LocationDAO.addLocal(l));
        }
Exemple #22
0
        public ActionResult Index(string metatitle, int id, int attribute_pa_chon_chat_lieu_op_lung = 0, string cart_item_key = "")
        {
            if (metatitle.Length <= 0 || metatitle.Split('-').Count() <= 1)
            {
                return(RedirectToAction("NotFound", "Error"));
            }


            var product = ProductDAO.GetProductByID(id);

            if (product == null)
            {
                return(RedirectToAction("NotFound", "Error"));
            }
            product.avatar.OrderBy(x => x.displayorder);
            product.slide.OrderBy(x => x.displayorder);

            if (product.collectionid > 0)
            {
                ViewBag.CollectionName = BrandModel.GetCollectionByID(Convert.ToInt32(product.collectionid)).name;
            }
            else
            {
                ViewBag.BrandName = BrandModel.GetBrandByID(Convert.ToInt32(product.brandid)).name;
            }

            ViewBag.CurrentMaterialID = attribute_pa_chon_chat_lieu_op_lung;
            CartSession cart = new CartSession();

            if (!String.IsNullOrEmpty(cart_item_key))
            {
                List <CartSession> lstCartItem = Session["fancycart"] as List <CartSession>;
                if (lstCartItem != null)
                {
                    cart = lstCartItem.Where(x => x.ItemKey == cart_item_key).FirstOrDefault();
                }
            }
            if (cart == null)
            {
                cart = new CartSession();
            }
            if (!String.IsNullOrEmpty(cart.Order))
            {
                cart.OrderObject            = JsonConvert.DeserializeObject <dynamic>(cart.Order);
                cart.OrderObject_Additional = cart.OrderObject.product[0];
            }

            ViewBag.CurrentCartItem = cart;
            var commonInfo = LocationDAO.GetCommonInfoByID("commoninfo");

            ViewBag.CommonInfo = commonInfo;
            return(View(product));
        }
        public JsonResult GetListWardByDistrictID(int disid)
        {
            var listWard = LocationDAO.GetListWardByDistrictID(disid);

            return(Json(new
            {
                items = listWard.Select(x => new
                {
                    id = x.id,
                    text = x.name
                })
            }, JsonRequestBehavior.AllowGet));
        }
Exemple #24
0
 public void LoadDataToForm()
 {
     try
     {
         DataTable dt = new DataTable();
         dt = LocationDAO.Location_GetAll().Tables[0].Copy();
         dgvLocation.DataSource = dt;
     }
     catch (Exception ex)
     {
         clsMessages.ShowErrorException(ex);
     }
 }
Exemple #25
0
        public int updateLocation(int locationId, string nombre, string direccion, string encargado)
        {
            Local l = new Local()
            {
                Nombre    = nombre,
                Direccion = direccion,
                Telefono  = "0",
                Encargado = encargado,
                Id_Loc    = locationId
            };

            return(LocationDAO.updateLocal(l));
        }
        public JsonResult GetListDistrictByProvinceID(int proid)
        {
            var listDistrict = LocationDAO.GetListDistrictByProvinceID(proid);

            return(Json(new
            {
                items = listDistrict.Select(x => new
                {
                    id = x.id,
                    text = x.name
                })
            }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult ChekoutSuccess(string orderid = "")
        {
            if (string.IsNullOrEmpty(orderid))
            {
                return(RedirectToAction("Index"));
            }
            var commonInfo = LocationDAO.GetCommonInfoByID("commoninfo");

            ViewBag.CommonInfo = commonInfo;
            OrderBO order = OrderDAO.GetOrderByID(orderid);


            return(View(order));
        }
Exemple #28
0
        /// <summary>
        /// map the entity to the dao
        /// </summary>
        /// <param name="s"></param>
        /// <returns></returns>
        public LocationDAO MapToDao(Location l)
        {
            var mapper = LocationMapper.CreateMapper();

            if (l != null)
            {
                LocationDAO ldao = mapper.Map <LocationDAO>(l);
                return(ldao);
            }
            else
            {
                return(new LocationDAO());
            }
        }
        internal static List <Order> GetPastOrdersFromCustomer(Customer customer, P1Context _context)
        {
            List <Order> OrdersByCustomer = new List <Order>();

            var DB = _context;

            OrderDAO.LoadOrdersList(DB);
            OrderProductsDAO.LoadOrderProductsList(DB);
            ProductDAO.LoadProductsList(DB);
            LocationDAO.LoadLocationsList(DB);
            BillingDAO.LoadBillingList(DB);
            CustomerDAO.LoadCustomersList(DB);
            ShippingDAO.LoadShippingInfomrationList(DB);

            OrdersByCustomer = DB.OrdersList.Where(o => o.CustomerID == customer.CustomerID).ToList();

            for (int i = 0; i < OrdersByCustomer.Count; i++)
            {
                Order o = OrdersByCustomer[i];

                List <ProductInStock> prodsOrdered = new List <ProductInStock>();

                List <OrderProducts> prodIDsAndQuantityInOrder = DB.OrderProductsList.Where(op => op.OrderID == OrdersByCustomer[i].OrderID).ToList();
                foreach (OrderProducts OP in prodIDsAndQuantityInOrder)
                {
                    ProductInStock prodOrdered = new ProductInStock();
                    Product        p           = DB.ProductsList.First(p => p.ProductID == OP.ProductID);
                    prodOrdered.Name        = p.Name;
                    prodOrdered.Price       = p.Price;
                    prodOrdered.Description = p.Description;
                    prodOrdered.Quantity    = OP.Quantity;
                    prodsOrdered.Add(prodOrdered);
                }

                o.ShoppingCart = prodsOrdered;

                o.Billing = DB.BillingInformationList.First(b => b.BillingID == OrdersByCustomer[i].BillingID);

                o.Shipping = DB.ShippingInformation.First(s => s.ShippingID == OrdersByCustomer[i].ShippingID);

                o.Location = DB.LocationList.First(l => l.LocationID == OrdersByCustomer[i].LocationID);

                o.Customer = DB.CustomersList.First(c => c.CustomerID == OrdersByCustomer[i].CustomerID);

                OrdersByCustomer[i] = o;
            }
            return(OrdersByCustomer);
        }
        /*internal static List<Location> GetAllLocations(P1Context _context)
         * {
         *  List<Location> LocationList;
         *  var DB = _context;
         *  LocationDAO.LoadLocationsList(DB);
         *  LocationList = DB.LocationList;
         *  return LocationList;
         * }*/

        public static Location GetLocation(int LocationID, P1Context _context)
        {
            Location location = new Location();
            var      DB       = _context;

            LocationDAO.LoadLocationsList(DB);
            foreach (Location l in DB.LocationList)
            {
                if (l.LocationID == LocationID)
                {
                    location = l;
                    break;
                }
            }
            return(location);
        }