示例#1
0
        private void ShowHargaBrg(int rowIndex)
        {
            //  get key (KodeBrg)
            string kodeBrg = (string)DetilPenjualanTable.Rows[rowIndex]["BrgID"];

            //  get qty
            var qty = Convert.ToDecimal(DetilPenjualanTable.Rows[rowIndex]["Qty"]);

            if (qty <= 0)
            {
                qty = 1;
            }
            //  get harga
            var listHarga = _brgPriceBL.ListData(kodeBrg);

            if (listHarga != null)
            {
                //  karena ada qty pecahan, maka jk qty terkecil = 1 -> ubah jadi 0
                var itemHarga = listHarga.OrderBy(x => x.Qty).FirstOrDefault();
                if (itemHarga != null)
                {
                    itemHarga.Qty = 0;
                }
            }

            double harga  = 0;
            double diskon = 0;

            if (listHarga != null)
            {
                var dataHarga = listHarga
                                .Where(x => x.Qty <= qty)
                                .OrderByDescending(x => x.Qty)
                                .FirstOrDefault();

                if (dataHarga == null)
                {
                    dataHarga = listHarga
                                .OrderByDescending(x => x.Qty)
                                .FirstOrDefault();
                }

                harga  = dataHarga.Harga;
                diskon = dataHarga.Diskon;
            }


            if (kodeBrg.ToLower().Contains("jasa"))
            {
                harga  = Convert.ToDouble(DetilPenjualanTable.Rows[rowIndex]["Harga"]);
                diskon = Convert.ToDouble(DetilPenjualanTable.Rows[rowIndex]["Diskon"]);
            }
            DetilPenjualanTable.Rows[rowIndex]["Harga"]    = harga;
            DetilPenjualanTable.Rows[rowIndex]["Diskon"]   = diskon;
            DetilPenjualanTable.Rows[rowIndex]["SubTotal"] = (harga - diskon) * Convert.ToDouble(qty);
            ReCalcTotal();
        }
示例#2
0
        private void RefreshPrice(int rowIndex)
        {
            PriceGrid.Rows.Clear();
            var currentRow = BrgGrid.Rows[rowIndex];

            if (currentRow == null)
            {
                return;
            }

            var brgID = currentRow.Cells["BrgKodeCol"].Value;

            if (brgID == null)
            {
                return;
            }

            var brgPrice = _brgPriceBL.ListData(brgID.ToString());

            if (brgPrice == null)
            {
                return;
            }
            var stringPriceFlat = "";

            foreach (var item in brgPrice.OrderBy(x => x.Qty))
            {
                object[] rowData = { item.Qty, item.Harga, item.Diskon };
                PriceGrid.Rows.Add(rowData);

                var tempString = "";
                if (item.Qty != 1)
                {
                    tempString = string.Format("x{0:n2} = ", item.Qty);
                }

                tempString += string.Format("Rp.{0:n0}", item.Harga);

                if (item.Diskon != 0)
                {
                    tempString += string.Format(" - {0:n0}", item.Diskon);
                }

                stringPriceFlat += tempString;
                stringPriceFlat += " | ";
            }
            currentRow.Cells["BrgPriceCol"].Value = stringPriceFlat;
            BrgGrid.Refresh();
        }