Example #1
0
 private void _txtSalePrice_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(_txtSalePrice.Text) && CurrencyUtil.ToDecimal(_model.NewPrice) != 0 && (string.IsNullOrEmpty(_txtImportPrice.Text) || CurrencyUtil.ToDecimal(_model.NewCost) == 0))
     {
         _model.NewCost = CurrencyUtil.ToString(CurrencyUtil.ToDecimal(_model.NewPrice) / (decimal)1.3);
     }
 }
Example #2
0
        private void dgvItemsList_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (dgvItemsList.SelectedRows.Count <= 0)
                {
                    return;
                }

                TicketPriceConfiguration selectedItem = dgvItemsList.SelectedRows[0].DataBoundItem as TicketPriceConfiguration;

                tbPrice.Text   = CurrencyUtil.ToString(selectedItem.price);
                tbRemark.Text  = selectedItem.description;
                _selectedId    = selectedItem.id;
                _selectedClass = selectedItem.seat_class;

                rbUpper.Checked = selectedItem.seat_class == Constants.SeatClass.B.ToString();
                rbLower.Checked = selectedItem.seat_class == Constants.SeatClass.A.ToString();
                rbFloor.Checked = selectedItem.seat_class == Constants.SeatClass.S.ToString();
            }
            catch (Exception exc)
            {
                AppLogger.logError("dgvItemsList_SelectionChanged", exc);
            }
        }
Example #3
0
 private void tbPrice_Leave(object sender, EventArgs e)
 {
     if (!string.IsNullOrEmpty(tbPrice.Text) && CurrencyUtil.ToDecimal(_model.Price) != 0 && (string.IsNullOrEmpty(tbCost.Text) || CurrencyUtil.ToDecimal(_model.Cost) == 0))
     {
         _model.Cost = CurrencyUtil.ToString(CurrencyUtil.ToDecimal(_model.Price) / (decimal)1.3);
     }
 }
Example #4
0
        private void dgvOrdersList_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            decimal totalPayment = 0;

            try
            {
                if (e.ColumnIndex == 0 && e.RowIndex != -1)
                {
                    _checkedRows.Clear();
                    // Loops through every row and calculates the sum of checked rows
                    foreach (DataGridViewRow row in dgvOrdersList.Rows)
                    {
                        if (row.Cells[0].Value != null && (bool)row.Cells[0].Value == true)
                        {
                            decimal cost;
                            if (decimal.TryParse(row.Cells["TotalCostColumn"].Value.ToString(), out cost))
                            {
                                _checkedRows.Add(row);
                                totalPayment += cost;
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AppLogger.logError(this.ToString(), ex);
            }
            tbTotalPayment.Text        = CurrencyUtil.ToString(totalPayment);
            lblPaymentBalanceText.Text = CurrencyUtil.ToString(CalculateBalance());
        }
        private void dgvItemsList_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (dgvItemsList.SelectedRows.Count <= 0)
                {
                    return;
                }

                TicketReturnFeeConfiguration selectedItem = dgvItemsList.SelectedRows[0].DataBoundItem as TicketReturnFeeConfiguration;

                rbAmount.Checked  = selectedItem.fee_amount > 0;
                rbPercent.Checked = selectedItem.fee_percent > 0;

                tbId.Text         = selectedItem.id;
                tbBeforeDate.Text = selectedItem.before_day.ToString();
                tbBeforeHour.Text = selectedItem.before_hour.ToString();
                tbAmount.Text     = CurrencyUtil.ToString(selectedItem.fee_amount);
                tbPercent.Text    = selectedItem.fee_percent.ToString();
            }
            catch (Exception exc)
            {
                AppLogger.logError("dgvItemsList_SelectionChanged", exc);
            }
        }
Example #6
0
 private void LoadOrderInfo(IrregularOrder order, Collection <OrderItem> items)
 {
     lblOrderIDText.Text              = order.id;
     lblOrderStatusText.Text          = EnumHelper.Parse <Constants.DeliveryStatus>(order.order_status).GetDescription();
     tbTotalItemsQuantity.Text        = order.total_quantity.ToString();
     tbTotalCost.Text                 = CurrencyUtil.ToString(order.total_cost);
     dgvItemsList.AutoGenerateColumns = false;
     dgvItemsList.DataSource          = items;
     tbTotalPayment.Text              = CurrencyUtil.ToString(order.total_cost);
 }
        private void LoadExpenseDetail()
        {
            using (ThanhVanTranSysEntities context = new ThanhVanTranSysEntities())
            {
                var RevenueDetails = context.RevenueDetails.Where(i => i.revenue_id == _revenueId).ToList();
                dgvFinacial.DataSource = RevenueDetails;

                tbTotalAmount.Text = CurrencyUtil.ToString(RevenueDetails.Sum(i => i.amount));
            }
        }
 private void SetValueToTicketControl(Ticket ticket)
 {
     lblTicketId.Text      = ticket.id;
     tbPassengerName.Text  = ticket.passenger_name.Trim();
     tbIDCardNumber.Text   = ticket.passenger_id_card_no.Trim();
     tbPickupLocation.Text = ticket.pickup_location.Trim();
     tbPhoneNumber.Text    = ticket.phone;
     lblSeatNo.Text        = ticket.seat_class + ticket.seat_number.ToString(CultureInfo.InvariantCulture);
     lblPrice.Text         = CurrencyUtil.ToString(GetPriceBySeatClass(_seatClass.ToString()));
     lblCreateBy.Text      = ticket.user_id;
 }
 private void OnControlUnFocus(object sender, EventArgs e)
 {
     if (((Control)sender).Enabled)
     {
         ValidateInput();
         decimal totalCost = CalculateTotalCost(OrderItem.weight, OrderItem.size, OrderItem.value, OrderItem.quantity);
         if (!this.tbTotalCost.Enabled)
         {
             this.tbTotalCost.Text = CurrencyUtil.ToString(totalCost);
         }
     }
 }
        private void tbRealAmount_TextChanged(object sender, EventArgs e)
        {
            try
            {
                base.CurrencyTextBox_TextChanged(sender, e);

                lblPaymentChange.Text = CurrencyUtil.ToString(CaculatePaymentChange());
            }
            catch (Exception exc)
            {
                AppLogger.logError(this.ToString(), exc);
            }
        }
        private void tbExpense_TextChanged(object sender, EventArgs e)
        {
            try
            {
                base.CurrencyTextBox_TextChanged(sender, e);

                lblProfit.Text = CurrencyUtil.ToString(CaculateProfit());
            }
            catch (Exception exc)
            {
                AppLogger.logError(this.ToString(), exc);
            }
        }
Example #12
0
 private void LoadOrderDetails(RegularOrder order)
 {
     try
     {
         lblOrderStatusText.Text   = EnumHelper.Parse <Constants.DeliveryStatus>(order.order_status).GetDescription();
         lblPaymentStatusText.Text = EnumHelper.Parse <Constants.PaymentStatus>(order.payment_status).GetDescription();
         tbItemsCount.Text         = order.total_quantity.ToString();
         tbOrderCost.Text          = CurrencyUtil.ToString(order.total_cost);
         dgvItemsList.DataSource   = _orderItemBusiness.GetByOrderId(order.id);
     }
     catch (Exception ex)
     {
         AppLogger.logError(this.ToString(), ex);
     }
 }
        private void tbAdjustmentAmount_TextChanged(object sender, EventArgs e)
        {
            try
            {
                base.CurrencyTextBox_TextChanged(sender, e);

                tbIncludeAdjustment.Text = CurrencyUtil.ToString(CurrencyUtil.ToDecimal(tbTotalPayment.Text) + CurrencyUtil.ToDecimal(tbAdjustmentAmount.Text));

                lblPaymentChange.Text = CurrencyUtil.ToString(CaculatePaymentChange());
            }
            catch (Exception exc)
            {
                AppLogger.logError(this.ToString(), exc);
            }
        }
Example #14
0
        private void tbPaidAmount_TextChanged(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(tbPaidAmount.Text))
            {
                tbPaymentChange.Text           = CurrencyUtil.ToString((CurrencyUtil.ToDecimal(tbPaidAmount.Text) - CurrencyUtil.ToDecimal(tbTotalPayment.Text)));
                btnSellAndPrintReceipt.Enabled = CurrencyUtil.ToDecimal(tbPaidAmount.Text) >= CurrencyUtil.ToDecimal(tbTotalPayment.Text);
                btnSell.Enabled = CurrencyUtil.ToDecimal(tbPaidAmount.Text) >= CurrencyUtil.ToDecimal(tbTotalPayment.Text);

                CurrencyTextBox_TextChanged(sender, e);
            }
            else
            {
                tbPaymentChange.Text = "0";
            }
        }
 public static TicketReportEntity ConvertFromReportEntity(Ticket tickets, Bus bus, Tour tour)
 {
     return(new TicketReportEntity()
     {
         BusName = bus.name,
         DepartTime = tickets.departure_time.ToString("dd-MM-yyyy"),
         PassengerIdNo = tickets.passenger_id_card_no,
         PassengerName = tickets.passenger_name,
         Phone = tickets.phone,
         SeatClass = tickets.seat_class,
         SeatNumber = tickets.seat_number.ToString(),
         Cost = tickets.cost,
         CostString = CurrencyUtil.ToString(tickets.cost),
         TourName = string.Format("{0} -> {1}", tour.start, tour.destination)
     });
 }
Example #16
0
        protected virtual void CurrencyTextBox_TextChanged(object sender, EventArgs e)
        {
            TextBox currencyTextBox = (TextBox)sender;
            decimal value           = 0;
            int     pos             = 0;

            if (string.IsNullOrWhiteSpace(currencyTextBox.Text))
            {
                currencyTextBox.Text = "0";
            }
            else if (decimal.TryParse(currencyTextBox.Text, out value))
            {
                pos = CurrencyUtil.ToString(value).Length;
                currencyTextBox.Text           = CurrencyUtil.ToString(value);
                currencyTextBox.SelectionStart = pos;
            }
        }
Example #17
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            try
            {
                ClearAll();

                decimal totalExpense = LoadExpenses(cbYearSearch.Text, cbMonthSearch.Text);
                decimal totalRevenue = LoadRevenues(cbYearSearch.Text, cbMonthSearch.Text);

                tbTotalExpense.Text = CurrencyUtil.ToString(totalExpense);
                tbTotalRevenue.Text = CurrencyUtil.ToString(totalRevenue);
                tbTotalProfit.Text  = CurrencyUtil.ToString(totalRevenue - totalExpense);
            }
            catch (Exception exc)
            {
                AppLogger.logError("btnSearch_Click", exc.ToString());
            }
        }
        private void LoadSeatMapData()
        {
            ClearTicketInfo();

            _seatClass =
                rbtnUpperSeat.Checked ? Constants.SeatClass.B :
                rbtnLowerSeat.Checked ? Constants.SeatClass.A : Constants.SeatClass.S;
            _busId         = cboBusName.SelectedValue.ToString();
            _tourId        = cboTour.SelectedValue.ToString();
            _departureTime = dtDepartureTime.Value;

            ucSeatMap.InitSeatMap(_seatClass);
            var reservedTickets = new TicketBusiness().GetAll(_busId, _tourId, _seatClass.ToString(), _departureTime).ToList();

            ucSeatMap.LoadTicket(reservedTickets);

            lblPrice.Text = CurrencyUtil.ToString(GetPriceBySeatClass(_seatClass.ToString()));
            _isEmptySeat  = false;
        }
        public void LoadCustomer(string seatNumber, Constants.SeatClass seatClass, Ticket ticket)
        {
            ClearTicketInfo();
            lblPrice.Text = CurrencyUtil.ToString(GetPriceBySeatClass(_seatClass.ToString()));

            if (ticket != null)
            {
                SetValueToTicketControl(ticket);
                _isEmptySeat  = false;
                _ticketUserId = ticket.user_id;
            }
            else
            {
                lblSeatNo.Text = seatClass + seatNumber;
                _isEmptySeat   = true;
                _seatNumber    = int.Parse(seatNumber);
                _ticketUserId  = null;
            }
        }
        private void SearchTicket()
        {
            ClearAll();
            string busId  = this.cbBus.SelectedValue.ToString();
            string tourId = this.cbTour.SelectedValue.ToString();

            _tickets = _ticketBusiness.GetAll().Where(t => t.bus_id.Equals(busId) &&
                                                      t.tour_id.Equals(tourId) &&
                                                      t.status.Equals(Constants.TicketStatus.Closed.ToString()) == false &&
                                                      t.departure_time.Year == this.dtpDepature.Value.Year &&
                                                      t.departure_time.Month == this.dtpDepature.Value.Month &&
                                                      t.departure_time.Day == this.dtpDepature.Value.Day).OrderBy(i => i.seat_class).ThenBy(i => i.seat_number).ToList();
            dgvTicketsList.DataSource = _tickets;

            _totalRevenue            = _tickets.Sum(i => i.cost);
            tbTotalPayment.Text      = CurrencyUtil.ToString(_totalRevenue);
            tbIncludeAdjustment.Text = CurrencyUtil.ToString(_totalRevenue);
            tbRealAmount.Text        = "0";
            lblPaymentChange.Text    = "0";
        }
Example #21
0
        private void dgvExpenes_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (dgvExpenes.SelectedRows.Count <= 0)
                {
                    return;
                }

                Expense selectedItem = (Expense)dgvExpenes.SelectedRows[0].DataBoundItem;

                tbNameExpense.Text         = selectedItem.name;
                tbAmountExpense.Text       = CurrencyUtil.ToString(selectedItem.amount);
                tbRemarkExpense.Text       = selectedItem.description;
                lblCreateDateExpenses.Text = selectedItem.created_date.ToString("dd/MM/yyyy hh:mm:ss");
            }
            catch (Exception exc)
            {
                AppLogger.logError("dgvExpenes_SelectionChanged", exc.ToString());
            }
        }
        protected virtual void CurrencyTextBox_TextChanged(object sender, EventArgs e)
        {
            TextBox currencyTextBox = (TextBox)sender;
            decimal value           = 0;
            int     pos             = 0;

            if (string.IsNullOrWhiteSpace(currencyTextBox.Text))
            {
                currencyTextBox.Text = "0";
            }
            else if (decimal.TryParse(currencyTextBox.Text, out value))
            {
                pos = currencyTextBox.SelectionStart;
                currencyTextBox.Text           = CurrencyUtil.ToString(value);
                currencyTextBox.SelectionStart = pos;
            }
            else
            {
                SetControlError(currencyTextBox, "Giá trị không hợp lệ");
            }
        }
Example #23
0
        private void dgvRevenue_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (dgvRevenue.SelectedRows.Count <= 0)
                {
                    return;
                }

                Revenue selectedItem = (Revenue)dgvRevenue.SelectedRows[0].DataBoundItem;

                tbNameRevenue.Text        = selectedItem.name;
                tbAmountRevenue.Text      = CurrencyUtil.ToString(selectedItem.amount);
                tbRemarkRevenue.Text      = selectedItem.description;
                lblCreateDateRevenue.Text = selectedItem.created_date.ToString("dd/MM/yyyy hh:mm:ss");
                btnRevenueDetail.Enabled  = selectedItem.type.Equals(Constants.RevenueType.Other.ToString()) == false;
            }
            catch (Exception exc)
            {
                AppLogger.logError("dgvRevenue_SelectionChanged", exc.ToString());
            }
        }
        private void dgvTicketsList_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (dgvTicketsList.SelectedRows.Count <= 0)
                {
                    return;
                }

                var selectedItem = dgvTicketsList.SelectedRows[0].DataBoundItem as Ticket;

                lblCustomerNameText.Text = selectedItem.passenger_name;
                lblIDCardNumberText.Text = selectedItem.passenger_id_card_no;
                lblPhoneNumberText.Text  = selectedItem.phone;
                lblSeatNuumberText.Text  = selectedItem.seat_class + selectedItem.seat_number;
                tbTicketPrice.Text       = CurrencyUtil.ToString(selectedItem.cost);
            }
            catch (Exception exc)
            {
                AppLogger.logError(this.ToString(), exc);
            }
        }
        private void dgvFinacial_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (dgvFinacial.SelectedRows.Count <= 0)
                {
                    return;
                }

                var selectedItem = dgvFinacial.SelectedRows[0].DataBoundItem;

                tbId.Text           = _isRevenue ? ((Revenue)selectedItem).id : ((Expense)selectedItem).id;
                tbName.Text         = _isRevenue ? ((Revenue)selectedItem).name : ((Expense)selectedItem).name;
                tbAmount.Text       = _isRevenue ? CurrencyUtil.ToString(((Revenue)selectedItem).amount) : CurrencyUtil.ToString(((Expense)selectedItem).amount);
                tbRemark.Text       = _isRevenue ? ((Revenue)selectedItem).description : ((Expense)selectedItem).description;
                dtpCreateDate.Value = _isRevenue ? ((Revenue)selectedItem).created_date : ((Expense)selectedItem).created_date;
            }
            catch (Exception exc)
            {
                AppLogger.logError("dgvFinacial_SelectionChanged", exc);
            }
        }
Example #26
0
        private void OnTextChanged(object sender, EventArgs e)
        {
            int     pos        = 0;
            decimal value      = 0;
            decimal adjustment = 0;

            if (decimal.TryParse(tbRealPaidAmount.Text, out value))
            {
                pos = tbRealPaidAmount.SelectionStart;
                tbRealPaidAmount.Text           = value.ToString("N0");
                tbRealPaidAmount.SelectionStart = pos;
            }

            if (chkUseAdjustment.Checked && decimal.TryParse(tbAdjustmentAmount.Text, out adjustment))
            {
                pos = tbAdjustmentAmount.SelectionStart;
                tbAdjustmentAmount.Text           = adjustment.ToString("N0");
                tbAdjustmentAmount.SelectionStart = pos;
            }

            lblPaymentBalanceText.Text = CurrencyUtil.ToString(CalculateBalance());
        }
Example #27
0
        public void BindData()
        {
            Ticket firstTicket = ConfirmTickets.FirstOrDefault();

            if (firstTicket != null)
            {
                Bus bus = new BusBusiness().Get(firstTicket.bus_id);
                lblBusNameText.Text       = bus == null ? string.Empty : bus.id;
                lblIDCardNumberText.Text  = firstTicket.passenger_id_card_no;
                lblPassengerNameText.Text = firstTicket.passenger_name;
                lblPhoneNumberText.Text   = firstTicket.phone;
                lblDepartureDateText.Text = String.Format("{0:d/M/yyyy}", firstTicket.departure_time);
            }

            lblSeatNameText.Text = firstTicket.seat_class;
            foreach (var ticket in ConfirmTickets.OrderBy(i => i.seat_number))
            {
                lblSeatNameText.Text += ticket.seat_number + ",";
            }
            lblSeatNameText.Text = lblSeatNameText.Text.Remove(lblSeatNameText.Text.Length - 1);

            tbTotalPayment.Text = CurrencyUtil.ToString(ConfirmTickets.Sum(i => i.cost));
        }
        private void dgvFinacial_SelectionChanged(object sender, EventArgs e)
        {
            try
            {
                if (dgvFinacial.SelectedRows.Count <= 0)
                {
                    return;
                }

                var selectedItem = dgvFinacial.SelectedRows[0].DataBoundItem;

                tbId.Text           = ((RevenueDetail)selectedItem).id;
                tbObjectId.Text     = ((RevenueDetail)selectedItem).object_id;
                tbAmount.Text       = CurrencyUtil.ToString(((RevenueDetail)selectedItem).amount);
                tbRemark.Text       = ((RevenueDetail)selectedItem).description;
                dtpCreateDate.Value = ((RevenueDetail)selectedItem).created_date;
                lbCreatedBy.Text    = ((RevenueDetail)selectedItem).created_by;
            }
            catch (Exception exc)
            {
                AppLogger.logError("dgvFinacial_SelectionChanged", exc);
            }
        }
Example #29
0
 private void dgvCustomersList_SelectionChanged(object sender, EventArgs e)
 {
     try
     {
         if (!string.IsNullOrEmpty(SelectedCustomerID))
         {
             var customer = _business.Get(SelectedCustomerID);
             PopulateCustomerInfo(customer);
             string query = string.Format("it.recipient_id = '{0}'", SelectedCustomerID);
             List <RegularOrder>       orders       = _regularOrderBusiness.Search(query).ToList();
             Collection <RegularOrder> openOrders   = new Collection <RegularOrder>();
             Collection <RegularOrder> closedOrders = new Collection <RegularOrder>();
             foreach (RegularOrder order in orders)
             {
                 if (order.order_status.Equals(Constants.DeliveryStatus.Closed.ToString()))
                 {
                     closedOrders.Add(order);
                 }
                 else
                 {
                     openOrders.Add(order);
                 }
             }
             tbOrdersCount.Text     = openOrders.Count.ToString();
             tbTotalPayment.Text    = CurrencyUtil.ToString(openOrders.Sum(o => o.total_cost));
             btnCloseOrders.Enabled = openOrders.Count > 0;
             OpenOrders             = openOrders;
             ClosedOrders           = closedOrders;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show("Có lỗi xảy ra.", Constants.Messages.ERROR_CAPTION, MessageBoxButtons.OK, MessageBoxIcon.Error);
         AppLogger.logError(this.ToString(), ex);
     }
 }
Example #30
0
 private void ckbUseAdjustment_CheckedChanged(object sender, EventArgs e)
 {
     tbAdjustmentAmount.Enabled = chkUseAdjustment.Checked;
     tbAdjustmentReason.Enabled = chkUseAdjustment.Checked;
     lblPaymentBalanceText.Text = CurrencyUtil.ToString(CalculateBalance());
 }