Ejemplo n.º 1
0
        public IActionResult Details(string id)
        {
            ManufacturerRepo mRepo = new ManufacturerRepo(db);
            var make = mRepo.Get(id);

            return(View(make));
        }
Ejemplo n.º 2
0
        public IActionResult Edit(string id)
        {
            ManufacturerRepo mRepo = new ManufacturerRepo(db);
            Manufacturer     make  = mRepo.Get(id);

            return(View(make));
        }
Ejemplo n.º 3
0
        public IActionResult Index()
        {
            ManufacturerRepo    mRepo = new ManufacturerRepo(db);
            List <Manufacturer> mList = mRepo.GetAll();

            return(View(mList));
        }
Ejemplo n.º 4
0
        public void firstTest()
        {
            var manufacturerRepo = new ManufacturerRepo(db);
            var controller       = new ManufacturerController(db);
            int expected         = 3;
            var viewResult       = Assert.IsType <ViewResult>(controller.Index());
            var model            = Assert.IsType <List <Manufacturer> >(viewResult.Model);
            int actual           = model.Count;

            Assert.Equal(expected, actual);
        }
Ejemplo n.º 5
0
        public IActionResult Delete(string id)
        {
            bool success;

            success = new ManufacturerRepo(db).Delete(id);
            if (success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Error", "Index"));
            }
        }
Ejemplo n.º 6
0
        private void LoadDropDownList()
        {
            List <ProductType> ProductTypes = new ProductTypeRepo().GetAllProductType();

            ddlProductType.DataSource = ProductTypes;
            ddlProductType.DataBind();
            ddlProductType.Items.Insert(0, new ListItem("(All)", ""));

            List <Manufacturer> Manufacturers = new ManufacturerRepo().GetAllManufacturer();

            ddlManufacturer.DataSource = Manufacturers;
            ddlManufacturer.DataBind();
            ddlManufacturer.Items.Insert(0, new ListItem("(All)", ""));
        }
 protected void btnRemove_Click(object sender, EventArgs e)
 {
     try
     {
         LinkButton lnk = (LinkButton)sender;
         int        Id  = ToSQL.SQLToInt(lnk.CommandArgument);
         if (Id > 0)
         {
             int i = new ManufacturerRepo().DeleteManufacturer(Id);
             BindItemsList();
         }
     }
     catch
     {
     }
 }
Ejemplo n.º 8
0
        public IActionResult Edit(Manufacturer m)
        {
            bool success = false;

            if (ModelState.IsValid)
            {
                success = new ManufacturerRepo(db).Update(m);
            }
            if (success)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(RedirectToAction("Error", "Index"));
            }
        }
Ejemplo n.º 9
0
        private void initialize()
        {
            productVMRepo      = new ProductVMRepo();
            productRepo        = new ProductRepo();
            manufacturerVMRepo = new ManufacturerVMRepo();
            manufacturerRepo   = new ManufacturerRepo();
            supplierRepo       = new SupplierRepo();
            //add database update listener delegate
            productRepo.DatabaseUpdated += ProductsUpdateListener;

            dataGridViewProducts.DataSource = bsProducts;
            comboBoxManufacturer.DataSource = bsManufacturers;
            comboBoxSupplier.DataSource     = bsSuppliers;

            refreshProductsData();
            loadManufacturers();
            loadSuppliers();
        }
Ejemplo n.º 10
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            Manufacturer manufacturer = new Manufacturer();

            manufacturer.Name     = ToSQL.EmptyNull(txtName.Text);
            manufacturer.Phone    = ToSQL.EmptyNull(txtPhone.Text);
            manufacturer.Website  = ToSQL.EmptyNull(txtWebsite.Text);
            manufacturer.Note     = ToSQL.EmptyNull(txtNote.Text);
            manufacturer.IsActive = true;
            manufacturer.Address  = new Address()
            {
                Street1 = ToSQL.EmptyNull(txtStreet1.Text),
                Street2 = ToSQL.EmptyNull(txtStreet2.Text),
                City    = ToSQL.EmptyNull(txtCity.Text),
                State   = ToSQL.EmptyNull(txtState.Text),
                Country = ToSQL.EmptyNull(txtCountry.Text),
                ZipCode = ToSQL.EmptyNull(txtZipCode.Text)
            };
            int i = new ManufacturerRepo().CreateManufacturer(manufacturer);

            Response.Redirect("Management-Manafacturer.aspx");
        }
Ejemplo n.º 11
0
 private void AddManufacturerForm_Load(object sender, EventArgs e)
 {
     manufacturerRepo = new ManufacturerRepo();
 }