Exemplo n.º 1
0
        public void SaveTest()
        {
            var listOfHargaGrosir = new List <HargaGrosir>();

            listOfHargaGrosir.Add(new HargaGrosir {
                harga_ke = 1, harga_grosir = 15000, jumlah_minimal = 5, diskon = 1
            });
            listOfHargaGrosir.Add(new HargaGrosir {
                harga_ke = 2, harga_grosir = 13000, jumlah_minimal = 10, diskon = 1.5
            });
            listOfHargaGrosir.Add(new HargaGrosir {
                harga_ke = 3, harga_grosir = 10000, jumlah_minimal = 15, diskon = 2.5
            });

            var obj = new Produk
            {
                kode_produk         = "200111101234",
                nama_produk         = "Harga dengan grosir",
                satuan              = "",
                stok                = 10,
                minimal_stok        = 5,
                harga_beli          = 1000000,
                harga_jual          = 1500000,
                golongan_id         = "0a8b59e5-bb3b-4081-b963-9dc9584dcda6",
                stok_gudang         = 15,
                minimal_stok_gudang = 5
            };

            obj.list_of_harga_grosir = listOfHargaGrosir;

            var validationError = new ValidationError();

            var result = _bll.Save(obj, ref validationError);

            Console.WriteLine("Error : " + validationError.Message);

            Assert.IsTrue(result != 0);

            var newObj = _bll.GetByID(obj.produk_id);

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.produk_id, newObj.produk_id);
            Assert.AreEqual(obj.nama_produk, newObj.nama_produk);
            Assert.AreEqual(obj.satuan, newObj.satuan);
            Assert.AreEqual(obj.stok, newObj.stok);
            Assert.AreEqual(obj.harga_beli, newObj.harga_beli);
            Assert.AreEqual(obj.harga_jual, newObj.harga_jual);
            Assert.AreEqual(obj.kode_produk, newObj.kode_produk);
            Assert.AreEqual(obj.golongan_id, newObj.golongan_id);
            Assert.AreEqual(obj.minimal_stok, newObj.minimal_stok);
            Assert.AreEqual(obj.stok_gudang, newObj.stok_gudang);
            Assert.AreEqual(obj.minimal_stok_gudang, newObj.minimal_stok_gudang);
        }
Exemplo n.º 2
0
        public void SaveTest()
        {
            var obj = new Produk
            {
                kode_produk         = "201607000000521",
                nama_produk         = "Printer Epson L220 Inkjet",
                satuan              = "",
                stok                = 10,
                minimal_stok        = 5,
                harga_beli          = 1000000,
                harga_jual          = 1500000,
                golongan_id         = "0a8b59e5-bb3b-4081-b963-9dc9584dcda6",
                stok_gudang         = 15,
                minimal_stok_gudang = 5
            };

            var validationError = new ValidationError();

            var result = _bll.Save(obj, ref validationError);

            Console.WriteLine("Error : " + validationError.Message);

            Assert.IsTrue(result != 0);

            var newObj = _bll.GetByID(obj.produk_id);

            Assert.IsNotNull(newObj);
            Assert.AreEqual(obj.produk_id, newObj.produk_id);
            Assert.AreEqual(obj.nama_produk, newObj.nama_produk);
            Assert.AreEqual(obj.satuan, newObj.satuan);
            Assert.AreEqual(obj.stok, newObj.stok);
            Assert.AreEqual(obj.harga_beli, newObj.harga_beli);
            Assert.AreEqual(obj.harga_jual, newObj.harga_jual);
            Assert.AreEqual(obj.kode_produk, newObj.kode_produk);
            Assert.AreEqual(obj.golongan_id, newObj.golongan_id);
            Assert.AreEqual(obj.minimal_stok, newObj.minimal_stok);
            Assert.AreEqual(obj.stok_gudang, newObj.stok_gudang);
            Assert.AreEqual(obj.minimal_stok_gudang, newObj.minimal_stok_gudang);
        }
Exemplo n.º 3
0
        protected override void Simpan()
        {
            if (_isNewData)
            {
                _produk = new Produk();
            }

            if (_produk.list_of_harga_grosir.Count == 0)
            {
                var index = 0;
                foreach (var item in _listOfTxtHargaGrosir)
                {
                    var txtHargaGrosir     = _listOfTxtHargaGrosir[index];
                    var txtJumlahMinGrosir = _listOfTxtJumlahGrosir[index];
                    var txtDiskonGrosir    = _listOfTxtDiskonGrosir[index];

                    var hargaGrosir = new HargaGrosir
                    {
                        harga_ke       = index + 1,
                        harga_grosir   = NumberHelper.StringToDouble(txtHargaGrosir.Text),
                        jumlah_minimal = NumberHelper.StringToDouble(txtJumlahMinGrosir.Text, true),
                        diskon         = NumberHelper.StringToDouble(txtDiskonGrosir.Text, true)
                    };

                    _produk.list_of_harga_grosir.Add(hargaGrosir);

                    index++;
                }
            }
            else
            {
                var index = 0;
                foreach (var item in _produk.list_of_harga_grosir)
                {
                    var txtHargaGrosir     = _listOfTxtHargaGrosir[index];
                    var txtJumlahMinGrosir = _listOfTxtJumlahGrosir[index];
                    var txtDiskonGrosir    = _listOfTxtDiskonGrosir[index];

                    item.harga_grosir   = NumberHelper.StringToDouble(txtHargaGrosir.Text);
                    item.jumlah_minimal = NumberHelper.StringToDouble(txtJumlahMinGrosir.Text, true);
                    item.diskon         = NumberHelper.StringToDouble(txtDiskonGrosir.Text, true);

                    index++;
                }
            }

            var golongan = _listOfGolongan[cmbGolongan.SelectedIndex];

            _produk.golongan_id = golongan.golongan_id;
            _produk.Golongan    = golongan;

            _produk.kode_produk           = txtKodeProduk.Text;
            _produk.is_aktif              = chkAktif.Checked;
            _produk.nama_produk           = txtNamaProduk.Text;
            _produk.satuan                = txtSatuan.Text;
            _produk.harga_beli            = NumberHelper.StringToDouble(txtHargaBeli.Text);
            _produk.harga_jual            = NumberHelper.StringToDouble(txtHargaJual.Text);
            _produk.diskon                = NumberHelper.StringToDouble(txtDiskon.Text, true);
            _produk.persentase_keuntungan = NumberHelper.StringToDouble(txtKeuntungan.Text, true);
            _produk.stok                = NumberHelper.StringToDouble(txtStok.Text, true);
            _produk.stok_gudang         = NumberHelper.StringToDouble(txtStokGudang.Text, true);
            _produk.minimal_stok_gudang = NumberHelper.StringToDouble(txtMinStokGudang.Text, true);

            var result          = 0;
            var validationError = new ValidationError();

            using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
            {
                if (_isNewData)
                {
                    result = _bll.Save(_produk, ref validationError);
                }
                else
                {
                    result = _bll.Update(_produk, ref validationError);
                }

                if (result > 0)
                {
                    Listener.Ok(this, _isNewData, _produk);

                    if (_isNewData)
                    {
                        base.ResetForm(this);

                        chkAktif.Checked   = true;
                        txtKodeProduk.Text = this._bll.GetLastKodeProduk();
                        txtKodeProduk.Focus();
                    }
                    else
                    {
                        this.Close();
                    }
                }
                else
                {
                    if (validationError.Message.NullToString().Length > 0)
                    {
                        MsgHelper.MsgWarning(validationError.Message);
                        base.SetFocusObject(validationError.PropertyName, this);
                    }
                    else
                    {
                        MsgHelper.MsgDuplicate("kode produk");
                        txtKodeProduk.Focus();
                        txtKodeProduk.SelectAll();
                    }
                }
            }
        }
Exemplo n.º 4
0
        protected override void Simpan()
        {
            if (_isNewData)
            {
                _produk = new Produk();
            }

            var golongan = _listOfGolongan[cmbGolongan.SelectedIndex];

            _produk.golongan_id = golongan.golongan_id;
            _produk.Golongan    = golongan;

            _produk.kode_produk         = txtKodeProduk.Text;
            _produk.nama_produk         = txtNamaProduk.Text;
            _produk.satuan              = txtSatuan.Text;
            _produk.harga_beli          = NumberHelper.StringToDouble(txtHargaBeli.Text);
            _produk.harga_jual          = NumberHelper.StringToDouble(txtHargaJual.Text);
            _produk.stok                = NumberHelper.StringToDouble(txtStok.Text);
            _produk.stok_gudang         = NumberHelper.StringToDouble(txtStokGudang.Text);
            _produk.minimal_stok_gudang = NumberHelper.StringToDouble(txtMinStokGudang.Text);

            var result          = 0;
            var validationError = new ValidationError();

            if (_isNewData)
            {
                result = _bll.Save(_produk, ref validationError);
            }
            else
            {
                result = _bll.Update(_produk, ref validationError);
            }

            if (result > 0)
            {
                Listener.Ok(this, _isNewData, _produk);

                if (_isNewData)
                {
                    base.ResetForm(this);

                    txtKodeProduk.Text = this._bll.GetLastKodeProduk();
                    txtKodeProduk.Focus();
                }
                else
                {
                    this.Close();
                }
            }
            else
            {
                if (validationError.Message != null && validationError.Message.Length > 0)
                {
                    MsgHelper.MsgWarning(validationError.Message);
                    base.SetFocusObject(validationError.PropertyName, this);
                }
                else
                {
                    MsgHelper.MsgDuplicate("kode produk");
                    txtKodeProduk.Focus();
                    txtKodeProduk.SelectAll();
                }
            }
        }