Beispiel #1
0
        private void ManageProduct_Load(object sender, EventArgs e)
        {
            ListBrands     = brandRepository.GetAll();
            ListCategories = categoryRepository.GetAll();
            ListUnits      = unitRepository.GetAll();

            cbbrand.DataSource    = new BindingSource(ListBrands, null);
            cbbrand.DisplayMember = "name";
            cbbrand.ValueMember   = "brandid";

            cbcategory.DataSource    = new BindingSource(ListCategories, null);
            cbcategory.DisplayMember = "name";
            cbcategory.ValueMember   = "catid";

            cbunit.DataSource    = new BindingSource(ListUnits, null);
            cbunit.DisplayMember = "name";
            cbunit.ValueMember   = "unitid";

            if (Editmode)
            {
                lbtitle.Text             = "UBAH DATA BARANG";
                cbcategory.SelectedValue = ProductData.prodcat;
                cbbrand.SelectedValue    = ProductData.brandid;
                tbprodcode.Text          = ProductData.prodcode;
                tbprodname.Text          = ProductData.name;
                cbunit.SelectedValue     = ProductData.produnit;
                tbpurchaseprice.Text     = ProductData.purchaseprice.ToString();
                tbbarcodeno.Text         = ProductData.barcodeno.ToString();
            }
        }
Beispiel #2
0
        private void LoadData()
        {
            ListBrands = brandRepository.GetAll();

            gvbrand.Rows.Clear();


            foreach (var item in ListBrands.OrderBy(x => x.name))
            {
                gvbrand.Rows.Add(item.brandid,
                                 item.name,
                                 item.remark);
            }
        }
Beispiel #3
0
        private void LoadData()
        {
            //if (userdata.user_role == "kasir")
            //{
            //    btadditem.Visible = false;
            //    btedititem.Visible = false;
            //    btdeleteitem.Visible = false;
            //    btunitmanage.Visible = false;
            //    btmanagebrand.Visible = false;
            //}

            try
            {
                ListBrands     = brandRepository.GetAll().ToList();
                ListProducts   = productRepository.GetAll().ToList();
                ListCategories = categoryRepository.GetAll().ToList();
                ListUnits      = unitRepository.GetAll().ToList();
                var tempproductlist = new List <TempProdColumns>();

                if (ListProducts != null)
                {
                    foreach (var item in ListProducts)
                    {
                        var prodbrand = ListBrands.FirstOrDefault(x => x.brandid == item.brandid);
                        var prodcat   = ListCategories.FirstOrDefault(x => x.catid == item.prodcat);
                        var produnit  = ListUnits.FirstOrDefault(x => x.unitid == item.produnit);

                        var itemDetail = new TempProdColumns();
                        itemDetail.prodid        = item.prodid;
                        itemDetail.brandid       = item.brandid;
                        itemDetail.brand_name    = prodbrand != null ? prodbrand.name : " - ";
                        itemDetail.name          = item.name;
                        itemDetail.prodcat       = item.prodcat;
                        itemDetail.prodcat_name  = prodcat != null ? prodcat.name : " - ";
                        itemDetail.prodcode      = item.prodcode;
                        itemDetail.produnit      = item.produnit;
                        itemDetail.produnit_code = produnit != null ? produnit.unitcode : " - ";
                        itemDetail.purchaseprice = item.purchaseprice;
                        itemDetail.stocks        = item.stocks;
                        itemDetail.barcodeno     = item.barcodeno;
                        tempproductlist.Add(itemDetail);
                    }

                    gvproducts.Rows.Clear();


                    foreach (var item in tempproductlist.OrderBy(x => x.prodcat_name).ThenBy(x => x.brand_name).ThenBy(x => x.name))
                    {
                        gvproducts.Rows.Add(
                            item.prodid,
                            item.prodcat_name,
                            item.brand_name,
                            item.prodcode,
                            item.name,
                            item.produnit_code,
                            Utils.ToRupiah(item.purchaseprice),
                            item.barcodeno,
                            item.stocks
                            );
                    }
                }



                var cbData = ListBrands;
                cbData.Insert(0, new BrandColumns {
                    brandid = -1, name = "--- Pilih Merek ---"
                });

                cbbrand.DataSource    = new BindingSource(ListBrands, null);
                cbbrand.DisplayMember = "name";
                cbbrand.ValueMember   = "brandid";

                var cbcatdata = ListCategories;
                cbcatdata.Insert(0, new CategoryColumns {
                    catid = -1, name = "--- Pilih Kategori ---"
                });

                cbcategory.DataSource    = new BindingSource(ListCategories, null);
                cbcategory.DisplayMember = "name";
                cbcategory.ValueMember   = "catid";
            }
            catch (Exception ex)
            {
                var errMsg = "Details : " + ex.Message + Environment.NewLine + "Stacktrace : " + ex.StackTrace;
                MessageBox.Show(errMsg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            tbprodname.Focus();
        }
Beispiel #4
0
        public ActionResult IndexBrand()
        {
            var model = brandRepo.GetAll();

            return(View(model));
        }
Beispiel #5
0
        private void btsave_Click(object sender, EventArgs e)
        {
            ListBrands = brandRepository.GetAll();
            int samename = 0;

            if (Editmode)
            {
                foreach (var existingdetails in ListBrands)
                {
                    if (existingdetails.name == tbbrandname.Text && existingdetails.brandid != BrandData.brandid)
                    {
                        samename += 1;
                        break;
                    }
                }


                if (tbbrandname.Text == "")
                {
                    MessageBox.Show("Yang bertanda Bintang tidak boleh kosong");
                }
                else if (samename > 0)
                {
                    MessageBox.Show("Nama brand yang anda masukkan sudah terdaftar");
                    samename = 0;
                }
                else
                {
                    var BrandDataBefore = new BrandColumns();
                    BrandDataBefore.name   = BrandData.name;
                    BrandDataBefore.remark = BrandData.remark;

                    BrandData.name       = tbbrandname.Text;
                    BrandData.remark     = tbremark.Text;
                    BrandData.updated_by = userdata.username;

                    bool havechanges = false;

                    if (BrandDataBefore.name == BrandData.name && BrandDataBefore.remark == BrandData.remark)
                    {
                        havechanges = true;
                    }


                    if (havechanges)
                    {
                        MessageBox.Show("Tidak ada data yang anda ubah");
                        BrandData.name   = BrandDataBefore.name;
                        BrandData.remark = BrandDataBefore.remark;
                    }
                    else if (brandRepository.Update(BrandData))
                    {
                        MessageBox.Show("Data telah berhasil di ubah");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Data gagal di ubah");
                        BrandData.name   = BrandDataBefore.name;
                        BrandData.remark = BrandDataBefore.remark;
                    }
                }
            }
            else
            {
                foreach (var existingdetails in ListBrands)
                {
                    if (existingdetails.name == tbbrandname.Text)
                    {
                        samename += 1;
                        break;
                    }
                }



                if (tbbrandname.Text == "")
                {
                    MessageBox.Show(" Yang bertanda Bintang tidak boleh kosong");
                }
                else if (samename > 0)
                {
                    MessageBox.Show("Nama brand yang anda masukkan sudah terdaftar");
                    samename = 0;
                }
                else
                {
                    var brand = new BrandColumns();

                    brand.name       = tbbrandname.Text;
                    brand.remark     = tbremark.Text;
                    brand.created_by = userdata.username;


                    if (brandRepository.Add(brand))
                    {
                        MessageBox.Show("Data baru telah berhasil di tambahkan");
                        Close();
                    }
                    else
                    {
                        MessageBox.Show("Data baru gagal ditambahkan");
                    }
                }
            }
        }
        public PartialViewResult BrandMenu()
        {
            var model = brandRepo.GetAll();

            return(PartialView("_BrandMenu", model));
        }