Esempio n. 1
0
        public bool removeProductFromStock(int storeId, int ProductId, int amountToRemove)
        {
            Store store = WorkShop.getStore(storeId);

            store.GetStockAsDictionary()[ProductId].amount -= amountToRemove;
            return(true);
        }
Esempio n. 2
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,WorkShopCode,WorkShopName,DistributerId,Address,Email,ContactPerson,MobileNumber,CreatedOn")] WorkShop workShop)
        {
            if (id != workShop.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workShop);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkShopExists(workShop.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DistributerId"] = new SelectList(_context.Distributor, "Id", "DistributorName", workShop.DistributerId);
            return(View(workShop));
        }
Esempio n. 3
0
        public static bool AddProductToStock(User user, int storeId, int productId, int amount)
        {
            Store store = WorkShop.getStore(storeId);

            if (store == null)
            {
                throw new Exception("Store does not exist");
            }
            if (!store.isActive)
            {
                notActiveStoreError();
            }

            Product product = store.getProduct(productId);

            if (product == null)
            {
                throw new Exception("Product does not exist in store id" + storeId);
            }


            if (!store.addProductTostock(user, product, amount))
            {
                throw new Exception("User does not have permission");
            }

            WorkShop.Update(store);

            return(true); //All Valid
        }
Esempio n. 4
0
        public void UpdateWorkShop(WorkShop subject)
        {
            try
            {
                var db       = new ApplicationDbContext();
                var workShop = db.WorkShops.Where(s => s.WorkshopID == subject.WorkshopID).SingleOrDefault();

                workShop.Name              = subject.Name;
                workShop.Address           = subject.Address;
                workShop.PhoneNumber       = subject.PhoneNumber;
                workShop.MobilePhoneNumber = subject.MobilePhoneNumber;
                workShop.Email             = subject.Email;


                db.SaveChanges();
                ErrorLabel.Text = String.Empty;
            }
            catch (DbEntityValidationException ex)
            {
                ErrorLabel.Visible = true;
                ErrorLabel.Text    = EventLogManager.LogError(ex);
            }
            catch (Exception exp)
            {
                ErrorLabel.Text    = exp.Message;
                ErrorLabel.Visible = true;
            }
        }
Esempio n. 5
0
        protected void grdWorkShopDetails_SelectedIndexChanged(object sender, EventArgs e)
        {
            objWork    = new WorkShopDetailsWB();
            objEntWork = new WorkShop();
            // Function used to  for downloading the files from database
            for (int i = 0; i < grdWorkShopDetails.Rows.Count; i++)
            {
                //obtain selected index from GridView for the selected File
                if (grdWorkShopDetails.SelectedIndex == i)
                {
                    //  int nominationID = int.Parse(grdWorkShopDetailsInternationalNationals.Rows[i].Cells[0].Text.Trim());
                    int nominationID = int.Parse(grdWorkShopDetails.DataKeys[i].Value.ToString());

                    //function call for the downloading the file and reading
                    // from database
                    objEntWork = objWork.readerForWorkShop("", nominationID);


                    //---------------------------- Reading of File--------------------------
                    //Information Stored in database is in the form of Binary
                    //Populates an array of objects with the column values of the current row.

                    if (objEntWork != null)
                    {
                        Byte[] programFile = objEntWork.ProgramFile;

                        //obtain content type from database, read the no of rows in the table
                        //Check Whether is their any information available in the database or not
                        if (objEntWork.NominationID != null)
                        {
                            //obtain content type of file, i.e., application/pdf, application/ vnd.msword

                            string contentType = objEntWork.Contenttype;
                            //obtaing filename from the table
                            string fileName = objEntWork.FileName;
                            //The ContentType property specifies the HTTP content type for the response.
                            //If no ContentType is specified, the default is text/HTML.
                            Response.ContentType = contentType;
                            //The AddHeader method adds a new HTML header and value to the response sent to the client
                            Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
                            //The Charset property appends the name of the character set (for example, ISO-8859-13) to the content-type header in the Response object
                            //Here Blank is attached
                            Response.Charset = "";
                            //Provides enumerated values that are used to set the Cache-Control HTTP header.
                            Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        }

                        //Provides enumerated values that are used to set the Cache-Control HTTP header.
                        Response.BinaryWrite(programFile);
                        //The End method causes the Web server to stop
                        //  processing the script and return the current result.
                        Response.End();
                    }
                    else
                    {
                        lblMessage.Text = "File DoesNot Exists";
                    }
                }
            }
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id,Description,IsDeleted,TimeDeleted,EventId")] WorkShop workShop)
        {
            if (id != workShop.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workShop);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkShopExists(workShop.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EventId"] = new SelectList(_context.Events, "Id", "Image", workShop.EventId);
            return(View(workShop));
        }
Esempio n. 7
0
        public void InsertWorkShop()
        {
            var db       = new ApplicationDbContext();
            var workShop = new WorkShop();

            TryUpdateModel(workShop);
            if (ModelState.IsValid)
            {
                try
                {
                    db.WorkShops.Add(workShop);
                    db.SaveChanges();
                    ErrorLabel.Text = String.Empty;
                }
                catch (DbEntityValidationException ex)
                {
                    ErrorLabel.Visible = true;
                    ErrorLabel.Text    = EventLogManager.LogError(ex);
                }
                catch (Exception exp)
                {
                    ErrorLabel.Text    = exp.Message;
                    ErrorLabel.Visible = true;
                }
            }
            else
            {
                ErrorLabel.Text    = "Complete todos los campos.";
                ErrorLabel.Visible = true;
            }
        }
Esempio n. 8
0
        private void ButtonDeleteClick(object sender, EventArgs e)
        {
            CommonCollection <WorkShop> stores = new CommonCollection <WorkShop>();

            foreach (ReferenceStatusImageLinkLabel item in _controlItems)
            {
                stores.Add((WorkShop)item.Tag);
            }
            CommonDeletingForm cdf = new CommonDeletingForm(typeof(WorkShop), stores);

            if (cdf.ShowDialog() == DialogResult.OK)
            {
                if (cdf.DeletedObjects.Count == 0)
                {
                    return;
                }

                foreach (BaseEntityObject o in cdf.DeletedObjects)
                {
                    WorkShop s = o as WorkShop;
                    if (s != null)
                    {
                        _itemsollection.Remove(s);
                    }
                }
                FillUiElementsFromCollection();
            }
        }
Esempio n. 9
0
    public Core(Color color, GameObject positionCore)
    {
        this.color        = color;
        this.PositionCore = positionCore;
        lvl         = 1;
        name        = "База";
        peopleLimit = 1000;

        building.Add(this);
        this.eventAddArmy   += AddLimitArmy;
        this.eventAddPeople += AddLimitPeople;

        workShop = new WorkShop();
        building.Add(workShop);

        storage = new Storage();
        storage.eventAddPeople += AddLimitPeople;
        building.Add(storage);

        walls = new Walls();
        building.Add(walls);

        barrack = new Barrack();
        barrack.eventAddArmy += AddLimitArmy;
        building.Add(barrack);

        portal = new Portal();
        building.Add(portal);

        resources = new GameResources(200, 300, 500, 0);
        UpPriceImprovement();
    }
Esempio n. 10
0
        public static bool AddProductToBasket(User user, int storeId, int productId, int amount)
        {
            bool           ret;
            ShoppingBasket userShoppingBasket = user.shoppingBasket;
            Store          store = WorkShop.getStore(storeId);
            Product        product;

            if (store != null && (product = store.findProduct(productId)) != null)
            {
                bool sucss;
                sucss = userShoppingBasket.addProduct(store, product, amount);
                if (sucss)
                {
                    ret = true;
                    Update(user);
                }
                else
                {
                    ret = false;
                }
            }
            else
            {
                throw new Exception("Illegal Product id");
            }
            return(ret);
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dataGridView1.Columns[e.ColumnIndex].Name == "colBtn_drop")
            {
                WorkShop model = new WorkShop();
                model.Id = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["id"].Value);
                if (WorkShopHelper.Drop(model, new List <string>()
                {
                    "id"
                }))
                {
                    ShowDataGird(); MessageBox.Show("删除成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }

            if (dataGridView1.Columns[e.ColumnIndex].Name == "colBtn_alter")
            {
                WorkShop model = new WorkShop();
                model.Id     = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["Id"].Value);
                model.master = dataGridView1.Rows[e.RowIndex].Cells["master"].Value.ToString();
                model.name   = dataGridView1.Rows[e.RowIndex].Cells["name"].Value.ToString();
                model.sum    = Convert.ToInt32(dataGridView1.Rows[e.RowIndex].Cells["sum"].Value);
                if (WorkShopHelper.AlterByPK(model, "id"))
                {
                    ShowDataGird(); MessageBox.Show("修改成功", "", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }
Esempio n. 12
0
        private void newStore(int num)
        {
            string storeIdStr = menager.AddStore("store" + num);

            storeId[num] = JsonConvert.DeserializeObject <IdMessage>(storeIdStr).id;
            store[num]   = WorkShop.getStore(storeId[num]);
        }
Esempio n. 13
0
        public static bool RemoveProductFromStore(User user, int storeId, int productId)
        {
            Store store = WorkShop.getStore(storeId);

            if (store == null)
            {
                throw new Exception("Store does not exist");
            }
            if (!store.isActive)
            {
                notActiveStoreError();
            }

            Product product = store.getProduct(productId);

            if (product == null)
            {
                throw new Exception("Product does not exist in store id" + storeId);
            }

            if (!store.removeProductFromStore(user, product))
            {
                throw new Exception("Error: User does not have permission");
            }

            WorkShop.Update(store);

            return(true); //All Valid
        }
Esempio n. 14
0
        public static List <Product> SearchProducts(string name, string category, string keyword, double startPrice, double endPrice, int productRank, int storeRank)
        {
            List <Product> products = WorkShop.search(name, category, startPrice, endPrice, productRank, storeRank);

            return(products);
            //return JsonConvert.SerializeObject(products);
        }
Esempio n. 15
0
        public int addStore(string name, int rank, int ownerId)
        {
            Member owner = ConnectionStubTemp.getMember(ownerId);
            int    ret   = WorkShop.createNewStore(name, rank, true, owner);

            return(ret);
        }
        protected void grdNominationManagementSystem_SelectedIndexChanged(object sender, EventArgs e)
        {
            objEntWork  = new WorkShop();
            workshopObj = new WorkShopDetails();


            for (int i = 0; i < grdNominationManagementSystem.Rows.Count; i++)
            {
                if (grdNominationManagementSystem.SelectedIndex == i)
                {
                    int nominationID = int.Parse(grdNominationManagementSystem.DataKeys[i].Value.ToString());

                    string topic = grdNominationManagementSystem.Rows[i].Cells[2].Text;

                    objEntWork = workshopObj.readerForWorkShop("", nominationID);


                    Byte[] programFile = objEntWork.ProgramFile;

                    if (objEntWork.FileName != null)
                    {
                        string contentType = objEntWork.Contenttype;
                        string fileName    = objEntWork.FileName;
                        Response.ContentType = contentType;
                        Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
                        Response.Charset = "";
                        Response.Cache.SetCacheability(HttpCacheability.NoCache);
                        Response.BinaryWrite(programFile);
                        Response.End();
                    }
                }
            }
        }
Esempio n. 17
0
        private void ReferenceButtonAddDisplayerRequested(object sender, ReferenceEventArgs e)
        {
            //StoreForm form = new StoreForm(GlobalObjects.CasEnvironment.Operators[0]);
            CommonEditorForm form = new CommonEditorForm(new WorkShop
            {
                Operator   = GlobalObjects.CasEnvironment.Operators[0],
                OperatorId = GlobalObjects.CasEnvironment.Operators[0].ItemId
            });

            if (form.ShowDialog() == DialogResult.OK)
            {
                if (form.CurrentObject as WorkShop == null)
                {
                    e.Cancel = true;
                    return;
                }
                WorkShop s = form.CurrentObject as WorkShop;

                _itemsollection.Add(s);
                FillUiElementsFromCollection();

                e.Cancel = true;

                //e.TypeOfReflection = ReflectionTypes.DisplayInNew;
                //e.DisplayerText = s.Name;
                //e.RequestedEntity = new StoreScreen(s);
            }
            else
            {
                e.Cancel = true;
            }
        }
        public Result <WorkShop> Save(WorkShop Entity)
        {
            var result = new Result <WorkShop>();

            try
            {
                var objtosave = _context.WorkShops.FirstOrDefault(u => u.WorkShopId == Entity.WorkShopId);
                if (objtosave == null)
                {
                    objtosave = new WorkShop();
                    _context.WorkShops.Add(Entity);
                }
                else
                {
                    objtosave = Entity;
                }

                if (!IsValid(objtosave, result))
                {
                    return(result);
                }


                _context.SaveChanges();
            }
            catch (Exception e)
            {
                result.HasError = true;
                result.Message  = e.Message;
            }

            return(result);
        }
Esempio n. 19
0
        private void deleteStore(string storeName)
        {
            Store store = InitSystem.getStore(storeName);

            WorkShop.deleteStore(store.id);
            store = InitSystem.getStore(storeName);
            Assert.IsNull(store);
        }
Esempio n. 20
0
        public override List <ProductAmountPrice> Apply(List <ProductAmountPrice> products, User user)
        {
            Product            product     = WorkShop.findProduct(productId).Values.First();
            ProductAmountPrice freeProduct = new ProductAmountPrice(product, amount, 0);

            products.Add(freeProduct);
            return(products);
        }
Esempio n. 21
0
 public Policystatus removeSystemPolicy(User user, int policyId)
 {
     if (!loggedIn)
     {
         notLoggedInException();
     }
     return(WorkShop.removeSystemPolicy(user, policyId));
 }
Esempio n. 22
0
        public bool removeStore(int storeId, int ownerId)
        {
            Member owner = ConnectionStubTemp.getMember(ownerId);

            WorkShop.closeStore(storeId, owner);
            WorkShop.Remove(storeId);
            return(true);
        }
Esempio n. 23
0
 public void Cealup()
 {   //remove p0
     menager.closeStore(storeId[0]);
     WorkShop.Remove(storeId[0]);
     //remove p1
     menager.closeStore(storeId[1]);
     WorkShop.Remove(storeId[1]);
     DataAccessDriver.UseStub = false;
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                try
                {
                    //this.getLoan();
                    txtid.Attributes.Add("readonly", "readonly");

                    if (Session[clsConstant.TOKEN] == null)
                    {
                        UrlParameterPasser urlWrapper = new UrlParameterPasser();
                        urlWrapper.Url = "../Logout.aspx";
                        urlWrapper.PassParameters();
                    }
                    else
                    {
                        this.readRole();

                        //if (IsUpload == false)
                        //{
                        //    UrlParameterPasser urlWrapper = new UrlParameterPasser();
                        //    urlWrapper.Url = "../Logout.aspx";
                        //    urlWrapper.PassParameters();
                        //}
                        //else
                        //{
                        objEnt             = new WorkShop();
                        workShopDetailsObj = new WorkShopDetailsWB();
                        objNomDetails      = new NominationDetailsWB();
                        nomID = Session["SouthID"].ToString();
                        // nomID = Request.QueryString["nomI"];
                        objEnt = workShopDetailsObj.readerForWorkShop("", int.Parse(nomID));
                        DataTable dt = new DataTable();
                        dt = (DataTable)Session["SouthDT"];
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            if (dt.Rows[i]["iSouthExchangeID"].ToString() == nomID.ToString())
                            {
                                lblNomination.Text = "<b/>" + dt.Rows[i]["vsTopic"].ToString();
                                lblSeats.Text      = "" + dt.Rows[i]["iSeats"].ToString();
                            }
                        }


                        ViewState["iSouthID"] = null;
                        this.bindNominatedUser(Convert.ToInt32(Session["SouthID"].ToString()));
                    }
                    //} else close
                }
                catch (Exception ex)
                {
                    logger.Error(ex);
                }
            }
        }
Esempio n. 25
0
        public bool appointUserToStoreOwnership(int storeId, int newOwnerId, int storeOwnerId)
        {
            Store  store    = WorkShop.getStore(storeId);
            Member owner    = ConnectionStubTemp.getMember(storeOwnerId);
            Member newowner = ConnectionStubTemp.getMember(storeOwnerId);
            Roles  role     = new Roles(true, true, true, true, true, true, true, true, true);

            owner.addManager(newowner.username, role, store);
            return(true);
        }
Esempio n. 26
0
        public int addProductToStore(int storeId, string name, double price, string category, string desc, string keyword, int amount, int rank)
        {
            Store   store = WorkShop.getStore(storeId);
            Product p     = new Product(name, price, desc, category, rank, amount, storeId);

            //store.GetStock().Add(p.getId(), p);
            store.getStock().Add(new Stock(p));
            WorkShop.Update(store);
            return(p.getId());
        }
Esempio n. 27
0
 void Apply_Explain_text_To_event()
 {
     Club_Merge.Get_Explain_Text("동아리가 합쳐졌다!");
     Club_Closing.Get_Explain_Text("동아리가 폐쇄되었다 ㅠㅠ");
     Get_Other_Club.Get_Explain_Text("다른 동아리가 우리에게 합쳐졌다");
     Nitpicking_From_Dep_Office.Get_Explain_Text("과사에서 청소하라고 잔소리한다");
     Black_Out.Get_Explain_Text("미래관이 정전되어서 실습실 컴퓨터를 사용할 수가 없다");
     WorkShop.Get_Explain_Text("컴퓨터공학과 동아리 워크숍을 진행했다");
     Exam_Period.Get_Explain_Text("시험기간이 찾아왔다");
 }
Esempio n. 28
0
        //[TestInitialize]
        public void Init()
        {
            DataAccessDriver.UseStub = true;
            ownerId    = god.addMember("username", "password");
            storeId    = god.addStore("store name", 1, ownerId);
            store      = WorkShop.getStore(storeId);
            storeOwner = ConnectionStubTemp.getMember(ownerId);
            int someMemberId = god.addMember("some member", "some password");

            someMember = ConnectionStubTemp.getMember(someMemberId);
        }
Esempio n. 29
0
        public static Product GetProductInfo(int productId)
        {
            Product product = WorkShop.getProduct(productId);

            if (product == null)
            {
                throw new Exception("Product does not exist in store id");
            }

            return(product);
        }
Esempio n. 30
0
        public void Init()
        {
            god = new GodObject();
            god.clearDb();
            User user = new User();

            user.registerNewUser("hadas", "ss", DateTime.Today.AddYears(-25), "A");
            storeOwner = ConnectionStubTemp.GetMemberByName("hadas");
            idStore    = WorkShop.createNewStore("TestPolicyStore", 10, true, storeOwner);
            store      = WorkShop.getStore(idStore);
        }