Пример #1
0
        private void BindProcurement()
        {
            lvproductQinstock.Items.Clear();
            lvproductQinstock.BeginUpdate();
            int index = 0;

            foreach (MorbiditySupplyProcurement p in _supplyProcurement)
            {
                LQTListViewTag tag = new LQTListViewTag();
                tag.GroupTitle = (p.PlatformEnum.ToString());
                tag.Id         = p.Id;
                tag.Index      = index;
                MasterProduct product = DataRepository.GetProductById(p.ProductId);

                ListViewItem li = new ListViewItem(product.ProductName)
                {
                    Tag = tag
                };

                li.SubItems.Add(p.PackSize.ToString());
                li.SubItems.Add(product.BasicUnit);
                li.SubItems.Add(p.QuantityNeeded.ToString());
                li.SubItems.Add(p.QuantityInStock.ToString());
                li.SubItems.Add(p.QuantityToPurchase.ToString());
                li.SubItems.Add(string.Format("{0:C}", p.UnitCost).ToString());
                li.SubItems.Add(string.Format("{0:C}", p.TotalCost).ToString());

                LqtUtil.AddItemToGroup(lvproductQinstock, li);

                lvproductQinstock.Items.Add(li);
                index++;
            }

            lvproductQinstock.EndUpdate();
        }
Пример #2
0
 private void butDeletepro_Click(object sender, EventArgs e)
 {
     if (lsvGroups.SelectedItems.Count > 0 && _error == false)//b
     {
         MasterProduct pro = this.GetSelectedProduct();
         if (pro != null && MessageBox.Show("Are you sure you want to delete this Product?", "Delete Product", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
         {
             try
             {
                 //_proType.Products.Remove(pro);
                 DataRepository.DeleteProduct(pro);
                 DataRepository.CloseSession();                                    //b
                 _proType = DataRepository.GetProductTypeById(pro.ProductType.Id); //b
             }
             catch (Exception ex)
             {
                 _error = true;
                 // throw new LQTUserException(ex.Message);
                 FrmShowError frm = new FrmShowError(new ExceptionStatus()
                 {
                     message = "Product could not be deleted.", ex = ex
                 });
                 frm.ShowDialog();
                 LQTUserMessage msg = SaveOrUpdateObject();//added b
                 this.Close();
             }
         }
         DisplayProducts();
     }
 }
        public async Task <ActionResult <dynamic> > PutMasterProduct(long productId, MasterProduct masterProduct)
        {
            if (productId != masterProduct.ProductId)
            {
                return(BadRequest());
            }

            IBusiness <MasterProduct> productBusiness = BusinessFactory <MasterProduct> .Create();

            bool isUpdate = false, isProductNameExisting = false;
            var  productModel = await productBusiness.SingleOrDefaultAsync(x => (bool)x.Status && x.ProductId == productId);

            if (productModel != null)
            {
                isProductNameExisting = await productBusiness.Any(x => x.ProductId != masterProduct.ProductId && (bool)x.Status && x.ProductName.ToLower() == masterProduct.ProductName.ToLower());

                if (!isProductNameExisting)
                {
                    productModel.ProductName = masterProduct.ProductName;
                    productModel.Quantity    = masterProduct.Quantity;
                    productModel.Price       = masterProduct.Price;
                    productModel.Availablity = masterProduct.Quantity <= 0 ? false : true;
                    productModel.Status      = masterProduct.Status;
                    productModel.EntryBy     = masterProduct.EntryBy;
                    productModel.EntryDate   = DateTime.Now;
                    isUpdate = await productBusiness.Update(productModel, productId);
                }
            }

            dynamic saveResult = new { isUpdate, isProductNameExisting };

            return(Ok(saveResult));
        }
Пример #4
0
        private void butAddP_Click(object sender, EventArgs e)
        {
            MasterProduct pro = LqtUtil.GetComboBoxValue <MasterProduct>(comProductP);

            if (pro != null)
            {
                if (comPeriodP.SelectedValue != null)
                {
                    if (!_consum.IsExsistUsageRatePerPeriod(pro.Id))
                    {
                        ConsumableUsage cu = new ConsumableUsage();
                        cu.Period           = comPeriodP.SelectedValue.ToString();
                        cu.PerPeriod        = true;
                        cu.Product          = pro;
                        cu.ProductUsageRate = 1;
                        cu.MasterConsumable = _consum;
                        _consum.ConsumableUsages.Add(cu);
                        BindProductUsageP();
                        if (OnDataUsageEdit != null)
                        {
                            OnDataUsageEdit(this, new EventArgs());
                        }
                    }
                }
            }
        }
Пример #5
0
        private void butAddI_Click_1(object sender, EventArgs e)
        {
            Instrument ins = LqtUtil.GetComboBoxValue <Instrument>(comInstrumentI);

            if (ins != null)
            {
                MasterProduct pro = LqtUtil.GetComboBoxValue <MasterProduct>(comProductI);
                if (pro != null)
                {
                    //if (! _consum.IsExsistProductUsage(ins.Id, pro.Id))
                    // {
                    if (comPeriodI.SelectedValue != null)
                    {
                        if (!_consum.IsExsistUsageRatePerInst(ins.Id, pro.Id))
                        {
                            ConsumableUsage cu = new ConsumableUsage();
                            cu.Period           = comPeriodI.Text;
                            cu.PerInstrument    = true;
                            cu.Product          = pro;
                            cu.Instrument       = ins;
                            cu.ProductUsageRate = 1;
                            cu.MasterConsumable = _consum;
                            _consum.ConsumableUsages.Add(cu);
                            BindProductUsageI();
                            if (OnDataUsageEdit != null)
                            {
                                OnDataUsageEdit(this, new EventArgs());
                            }
                        }
                    }
                }
            }
        }
Пример #6
0
        private void butAddT_Click(object sender, EventArgs e)
        {
            MasterProduct pro = LqtUtil.GetComboBoxValue <MasterProduct>(comProductT);

            if (pro != null)
            {
                if (!_consum.IsExsistUsageRatePerTest(pro.Id))
                {
                    if (txtNoofTest.Text != "0")
                    {
                        ConsumableUsage cu = new ConsumableUsage();
                        cu.NoOfTest         = int.Parse(txtNoofTest.Text);
                        cu.PerTest          = true;
                        cu.Product          = pro;
                        cu.ProductUsageRate = 1;
                        cu.MasterConsumable = _consum;
                        _consum.ConsumableUsages.Add(cu);
                        BindProductUsage();
                        if (OnDataUsageEdit != null)
                        {
                            OnDataUsageEdit(this, new EventArgs());
                        }
                    }
                }
            }
        }
Пример #7
0
        private void InitializeProductForm(MasterProduct pro)
        {
            ProductForm frm = new ProductForm(pro, _mdiparent);

            frm.ShowDialog();
            RebindProductType(_proType);
        }
Пример #8
0
        private void butAdd_Click(object sender, EventArgs e)
        {
            Instrument ins = LqtUtil.GetComboBoxValue <Instrument>(comInstrument);

            if (ins != null)
            {
                MasterProduct pro = LqtUtil.GetComboBoxValue <MasterProduct>(comProduct);
                if (pro != null)
                {
                    if (!_test.IsExsistProductUsage(ins.Id, pro.Id))
                    {
                        ProductUsage pu = new ProductUsage();
                        pu.Test       = _test;
                        pu.Instrument = ins;
                        pu.Product    = pro;
                        pu.Rate       = 1;
                        _test.ProductUsages.Add(pu);

                        BindProductUsage();
                        if (OnDataUsageEdit != null)
                        {
                            OnDataUsageEdit(this, new EventArgs());
                        }
                    }
                }
            }
        }
 public override CommandResult Handle(AddMasterProductCommand command)
 {
     if (IsValid(command))
     {
         var masterProductPhotoCollection = new List <MasterProductPhoto>();
         foreach (var photoUrlSize in command.DtoPhotoUrlSizes)
         {
             masterProductPhotoCollection.Add(new MasterProductPhoto {
                 Photo = new Photo {
                     Url = photoUrlSize.PhotoUrl, Size = photoUrlSize.PhotoSize
                 }
             });
         }
         MasterProduct masterProduct = new MasterProduct
         {
             MasterId            = command.MasterId,
             CategoryId          = command.CategoryId,
             Name                = command.Name,
             Price               = command.Price,
             Discount            = command.Discount,
             Description         = command.Description,
             ShortDescription    = command.ShortDescription,
             masterProductPhotos = masterProductPhotoCollection,
             MainPhoto           = new Photo {
                 Url = command.MainPhotoUrlSize.PhotoUrl, Size = command.MainPhotoUrlSize.PhotoSize
             }
         };
         _commandRepository.Add(masterProduct);
         return(Ok());
     }
     return(Failure());
 }
Пример #10
0
        public override CommandResult Handle(AddMasterProductCommand command)
        {
            if (IsValid(command))
            {
                var photos = new List <Photo>();

                foreach (var item in command.Photos)
                {
                    photos.Add(new Photo()
                    {
                        Url = item
                    });
                }


                MasterProduct masterProduct = new MasterProduct
                {
                    Name             = command.Name,
                    Price            = command.Price,
                    Discount         = command.Discount,
                    Description      = command.Description,
                    ShortDescription = command.ShortDescription,
                    MasterId         = command.MasterId,
                    CategoryId       = command.CategoryId,
                    Photos           = photos
                };
                _commandRepository.Add(masterProduct);
                return(Ok());
            }
            return(Failure());
        }
        public IActionResult Index()
        {
            List <Product> AllProducts = ProductList();

            MasterProduct MasterProduct = new MasterProduct(AllProducts);

            return(View(MasterProduct));
        }
Пример #12
0
        public void delete(MasterProduct dbitem)
        {
            context.MasterProduct.Remove(dbitem);
            var auditrail = new Auditrail {
                Actionnya = "Delete", EventDate = DateTime.Now, Modulenya = "Product", QueryDetail = "Delete " + dbitem.NamaProduk, RemoteAddress = AppHelper.GetIPAddress(), IdUser = 1
            };

            context.Auditrail.Add(auditrail);
            context.SaveChanges();
        }
Пример #13
0
 private void butNewpro_Click(object sender, EventArgs e)
 {
     if (CreateOrEditProduct != null)
     {
         MasterProduct pro = new MasterProduct();
         pro.ProductType = _proType;
         CreateOrUpdateEventArgs eArgs = new CreateOrUpdateEventArgs(pro);
         CreateOrEditProduct(this, eArgs);
     }
 }
Пример #14
0
        public ProductPane(MasterProduct pro, bool enableCtr)
        {
            this._product   = pro;
            this._enableCtr = enableCtr;

            InitializeComponent();
            SetControlState();
            PopProductType();
            BindProduct();
        }
Пример #15
0
        private void butSave_Click(object sender, EventArgs e)
        {
            int count = 0;
            int error = 0;

            try
            {
                foreach (ImportProductData rd in _rdata)
                {
                    if (!rd.IsExist)
                    {
                        if (!rd.HasError)
                        {
                            MasterProduct pro = new MasterProduct();
                            pro.ProductName     = rd.ProductName;
                            pro.SerialNo        = rd.Serial;
                            pro.BasicUnit       = rd.BasicUnit;
                            pro.ProductType     = rd.Category;
                            pro.Specification   = rd.Specification;
                            pro.MinimumPackSize = rd.minSize;
                            pro.RapidTestGroup  = rd.RapidTest;

                            ProductPrice pp = new ProductPrice();
                            pp.FromDate = rd.PriceDate;
                            pp.PackSize = rd.Packsize;
                            pp.Price    = rd.Price;

                            pro.ProductPrices.Add(pp);
                            count++;
                            DataRepository.SaveOrUpdateProduct(pro);
                        }
                        else
                        {
                            error++;
                        }
                    }
                    else
                    {
                        error++;
                    }
                }

                MessageBox.Show(count + " Products are imported and saved successfully." + Environment.NewLine + error + " Products Failed.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
                this.Close();
            }
            catch
            {
                MessageBox.Show("Error: Unable to import and save product data.", "Importing", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            finally
            {
                DataRepository.CloseSession();
            }
        }
Пример #16
0
        public ProductForm(MasterProduct pro, Form mdiparent)
        {
            this._product   = pro;
            this._mdiparent = mdiparent;

            InitializeComponent();

            lqtToolStrip1.SaveAndCloseClick += new EventHandler(lqtToolStrip1_SaveAndCloseClick);
            lqtToolStrip1.SaveAndNewClick   += new EventHandler(lqtToolStrip1_SaveAndNewClick);

            LoadProductCtr();
        }
Пример #17
0
        public void AddForecastProductHistory(int productid, int siteid, DateTime startdate)
        {
            IList <ForecastSiteProduct> historicalSiteProduct =
                DataRepository.GetHistoricalProduct(_forecastInfo.Period, _forecastInfo.Methodology, _forecastInfo.DataUsage, productid, siteid, startdate, noHistoryRecord);
            MasterProduct product = DataRepository.GetProductById(productid);

            foreach (ForecastSiteProduct fst in historicalSiteProduct)
            {
                fst.Product      = product;
                fst.ForecastSite = fsite;
                fsite.SiteProducts.Add(fst);
            }
            DataRepository.BatchSaveForecastSiteProduct(historicalSiteProduct);
        }
Пример #18
0
        private void butNewpro_Click(object sender, EventArgs e)
        {
            if (CreateOrEditProduct != null)
            {
                MasterProduct pro = new MasterProduct();
                pro.ProductType = _proType;
                CreateOrUpdateEventArgs eArgs = new CreateOrUpdateEventArgs(pro);
                CreateOrEditProduct(this, eArgs);

                _proType = DataRepository.GetProductTypeById(pro.ProductType.Id);//b
            }

            DisplayProducts();//b
        }
Пример #19
0
        private void butEditpro_Click(object sender, EventArgs e)
        {
            if (lsvGroups.SelectedItems.Count > 0 && _error == false)//b
            {
                if (CreateOrEditProduct != null)
                {
                    MasterProduct           pro   = GetSelectedProduct();             //b
                    CreateOrUpdateEventArgs eArgs = new CreateOrUpdateEventArgs(pro); //b

                    //  CreateOrUpdateEventArgs eArgs = new CreateOrUpdateEventArgs(GetSelectedProduct());
                    CreateOrEditProduct(this, eArgs);
                    _proType = DataRepository.GetProductTypeById(pro.ProductType.Id);//b
                }
                DisplayProducts();
            }
        }
Пример #20
0
        private void butDeletepro_Click(object sender, EventArgs e)
        {
            MasterProduct pro = this.GetSelectedProduct();

            if (pro != null && MessageBox.Show("Are you sure you want to delete this Product?", "Delete Product", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                try
                {
                    DataRepository.DeleteProduct(pro);
                }
                catch (Exception ex)
                {
                    throw new LQTUserException(ex.Message);
                }
            }
        }
 public IActionResult NewProduct(MasterProduct NewProduct)
 {
     if (ModelState.IsValid)
     {
         Product Product = new Product(NewProduct);
         dbContext.Products.Add(Product);
         dbContext.SaveChanges();
         return(RedirectToAction("Index"));
     }
     else
     {
         List <Product> AllProducts = ProductList();
         NewProduct.Products = AllProducts;
         return(View("Index", NewProduct));
     }
 }
        public async Task <ActionResult <dynamic> > PostMasterProduct(MasterProduct masterProduct)
        {
            IBusiness <MasterProduct> productBusiness = BusinessFactory <MasterProduct> .Create();

            bool isInsert = false, isProductNameExisting = false;

            isProductNameExisting = await productBusiness.Any(x => (bool)x.Status && x.ProductName.ToLower() == masterProduct.ProductName.ToLower());

            if (!isProductNameExisting)
            {
                isInsert = await productBusiness.Insert(masterProduct);
            }

            dynamic result = new { isInsert, isProductNameExisting };

            return(Ok(result));
        }
Пример #23
0
        public override bool DeleteSelectedItem()
        {
            int    delProCount = 0;
            string productName = null;

            if (MessageBox.Show("Are you sure you want to delete selected Product/s ?", "Delete Product", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                for (int i = 0; i < listView1.SelectedItems.Count; i++)
                {
                    try
                    {
                        DataRepository.DeleteProduct((MasterProduct)listView1.SelectedItems[i].Tag);
                        delProCount++;
                    }
                    catch
                    {
                        if (productName == null)
                        {
                            productName = ((MasterProduct)listView1.SelectedItems[i].Tag).ProductName + Environment.NewLine;
                        }
                        else
                        {
                            productName += ", " + ((MasterProduct)listView1.SelectedItems[i].Tag).ProductName + Environment.NewLine;
                        }
                    }
                }

                if (productName != null)
                {
                    MessageBox.Show("Some of Products listed below could not delete. " + Environment.NewLine + productName, "Delete selected Product(s)", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                if (delProCount > 0)
                {
                    MdiParentForm.ShowStatusBarInfo(delProCount + " Product/s deleted successfully.");
                }

                _selectedProId = null;
                //DataRepository.CloseSession();
                PopProduct();
                return(true);
            }

            return(false);
        }
Пример #24
0
        private void PopProduct()
        {
            _totalNoOfPro = DataRepository.GetTotalCountOfProducts(_proTypeId);

            _totalPages = Math.Ceiling(_totalNoOfPro / _pageSize);

            if (_pageNo > 0 && _pageNo == _totalPages)
            {
                _pageNo--;
            }
            _selectedProId = null;

            txtPageno.Text = _totalPages == 0 ? "0" : (_pageNo + 1).ToString();
            lblPages.Text  = _totalPages.ToString();

            BindProductToListView();
            SetNavButtonState();
        }
Пример #25
0
 private void listView1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (listView1.SelectedItems.Count > 0)
     {
         //int id = (int)listView1.SelectedItems[0].Tag;
         MasterProduct mp = listView1.SelectedItems[0].Tag as MasterProduct;
         //if (id != _selectedProId)
         if (_selectedProId == null)
         {
             _selectedProId = mp;
         }
         else if (mp.Id != _selectedProId.Id)
         {
             _selectedProId = mp; // id;
         }
     }
     SelectedItemChanged(listView1);
 }
Пример #26
0
        public virtual void AddItem(MasterProduct product, int quantity)
        {
            CartLine line = lineCollection
                            .Where(p => p.Product.Id == product.Id)
                            .FirstOrDefault();

            if (line == null)
            {
                lineCollection.Add(new CartLine
                {
                    Product  = product,
                    Quantity = quantity
                });
            }
            else
            {
                line.Quantity += quantity;
            }
        }
Пример #27
0
        void lqtToolStrip1_SaveAndNewClick(object sender, EventArgs e)
        {
            try
            {
                LQTUserMessage msg = SaveOrUpdateObject();
                ((LqtMainWindowForm)_mdiparent).ShowStatusBarInfo(msg.Message, true);
                //DataRepository.CloseSession();

                ProductType pt = _product.ProductType;

                _product             = new MasterProduct();
                _product.ProductType = pt;

                LoadProductCtr();
            }
            catch (Exception ex)
            {
                new FrmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
Пример #28
0
 public void save(MasterProduct dbitem)
 {
     if (dbitem.Id == 0) //create
     {
         context.MasterProduct.Add(dbitem);
         var auditrail = new Auditrail {
             Actionnya = "Add", EventDate = DateTime.Now, Modulenya = "Product", QueryDetail = "Add " + dbitem.NamaProduk, RemoteAddress = AppHelper.GetIPAddress(), IdUser = 1
         };
         context.Auditrail.Add(auditrail);
     }
     else //edit
     {
         context.MasterProduct.Attach(dbitem);
         var auditrail = new Auditrail {
             Actionnya = "Edit", EventDate = DateTime.Now, Modulenya = "Product", QueryDetail = "Edit " + dbitem.NamaProduk, RemoteAddress = AppHelper.GetIPAddress(), IdUser = 1
         };
         context.Auditrail.Add(auditrail);
         var entry = context.Entry(dbitem);
         entry.State = EntityState.Modified;
     }
     context.SaveChanges();
 }
Пример #29
0
        public async Task PostMasterProductTest()
        {
            var controller    = new MasterProductController();
            var masterProduct = new MasterProduct()
            {
                ProductName = "Moto X4",
                Quantity    = 20,
                Price       = 14000,
                Availablity = true,
                Status      = true,
                EntryBy     = 1,
                EntryDate   = DateTime.Now
            };

            var outputResult = await controller.PostMasterProduct(masterProduct);

            var  result = outputResult.Result;
            var  data   = result.TryGetPropertyValue <bool>("isInsert");
            Type type   = typeof(bool);

            Assert.IsNotNull(data);
        }
Пример #30
0
        public async Task PutMasterProductTest()
        {
            var controller    = new MasterProductController();
            int pkid          = 1;
            var masterProduct = new MasterProduct()
            {
                ProductId   = 1,
                ProductName = "IPhone series",
                Quantity    = 1,
                Price       = 80000,
                Availablity = true,
                Status      = true,
                EntryBy     = 1,
                EntryDate   = DateTime.Now
            };

            var outputResult = await controller.PutMasterProduct(pkid, masterProduct);

            var  result = outputResult.Result;
            var  data   = result.TryGetPropertyValue <bool>("isUpdate");
            Type type   = typeof(bool);

            Assert.IsNotNull(data);
        }