Beispiel #1
0
        /// <summary>
        /// In phiếu thu
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void cmdPrint_Click(object sender, EventArgs e)
        {
            var tmpId = grvMain.GetFocusedRowCellValue("Id");
            if (tmpId == null)
            {
                XtraMessageBox.Show(STR_CHOICE,
                    Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            var detail = _bll.Tra_Detail.Find((Guid)tmpId);

            bool _isFixed = detail.Vehicle.Fixed;
            var seat = detail.Seats ?? 0;
            var bed = detail.Beds ?? 0;

            var note = (detail.Repair ? Global.STR_TEMP_OUT : "")
                                 + (detail.Show ? "" : ", " + Global.STR_NOT_VALUE)
                                 + (detail.Note == null ? "" : ", " + detail.Note);
            if (detail.Vehicle.More.ToInt32() > 0)
                note += String.Format("Xe thu khoán {0} ghế", seat);
            if (detail.Text + "" == Global.STR_ARREAR)
                note += detail.Text;

            note = note.Replace(", ", "").Trim();

            // Xe cố định, không đi sửa, xe đủ điều kiện
            if (_isFixed && !detail.Repair && detail.Show) // in phiếu thu xe cố định
            {
                var rpt = new Report.Rpt_Receipt();
                var tbl = new Station.DataSet.Dts_Fixed.ReceiptDataTable();
                var dtr = tbl.NewRow();

                rpt.parUnit.Value = Global.Title2;
                rpt.parAddress.Value = Global.Address;

                var cost = detail.Price1 * seat + detail.Price2 * bed;
                var rose = detail.Rose1 * (seat < 1 ? 1 : seat - 1) + detail.Rose2 * bed;
                var arrears = (cost + rose) * detail.Arrears ?? 0;
                var total = detail.Money + arrears;

                dtr["Seri"] = String.Format("{0}/{1}", detail.Order, Global.Session.Current.Month);
                dtr["Date"] = Global.Session.Current;
                dtr["Number"] = detail.Vehicle.Code;
                dtr["Transport"] = detail.Vehicle.Transport.Text;

                dtr["CostDescript"] = String.Format("{0:#,0} x {1} + {2:#,0} x {3} = ",
                    detail.Price1, seat, detail.Price2, bed);
                dtr["RoseDescript"] = String.Format("{0:#,0} x {1} + {2:#,0} x {3} = ",
                    detail.Rose1, (seat < 1 ? 1 : seat - 1), detail.Rose2, bed);

                dtr["Cost"] = cost;
                dtr["Rose"] = rose;

                dtr["ArrearsDescript"] = String.Format("({0:#,0} + {1:#,0}) x {2} = ",
                    cost, rose, detail.Arrears ?? 0);

                dtr["Arrears"] = arrears;
                dtr["Money"] = total;

                dtr["Parked"] = detail.Parked;
                dtr["ByChar"] = total.ToVietnamese("đồng");
                dtr["Creator"] = Global.Session.User.Name;
                dtr["Tariff"] = detail.Vehicle.Tariff.Text;
                dtr["Note"] = note.IsNullOrEmpty() ? "" : String.Format("({0})", note.ToUpperFirst());

                tbl.Rows.Add(dtr);
                rpt.DataSource = tbl;

                try { rpt.Print(); }
                catch
                {
                    XtraMessageBox.Show("LỖI: MÁY KHÔNG IN ĐƯỢC!",
                        Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Tính tiền và cho xe ra bến
        /// </summary>
        /// <param name="isOut">Cho xe ra</param>
        private void Invoice(bool isOut = false, bool isRepair = true)
        {
            try
            {
                if (lkeNumber.Text == "") return;
                var detail = _bll.Tra_Detail.InvoiceOut(lkeNumber.Text, isOut, null,
                    isRepair, "", txtSeri.Text);

                _isFixed = detail.Vehicle.Fixed;
                var seat = detail.Seats ?? 0;
                var bed = detail.Beds ?? 0;

                var cost = detail.Price1 * seat + detail.Price2 * bed;
                var rose = detail.Rose1 * (seat < 1 ? 1 : seat - 1) + detail.Rose2 * bed;
                var arrears = (cost + rose) * detail.Arrears ?? 0;

                if (_isFixed)
                {
                    lblKind.Text = "Tuyến: " + detail.Vehicle.Tariff.Text;
                    lblGroup.Text = "ĐVVT: " + detail.Vehicle.Transport.Text;
                    lblHalfDay.Text = "Ghế:";
                    lblFullDay.Text = "Giường:";
                    lblTested.Text = detail.More + "" != "" ? Global.STR_TESTED : "";

                    if (detail.Arrears != null)
                    {
                        if (detail.Arrears > 0)
                            lblArrears.Text = String.Format("TRUY THU {0:#,0}L = {1:#,0đ}", detail.Arrears, arrears);
                    }

                    lblSeri.Visible = false;
                    txtSeri.Visible = false;
                }
                else
                {
                    lblSeri.Visible = !isOut;
                    txtSeri.Visible = !isOut;

                    if (isOut) txtSeri.Text = "";
                    else txtSeri.Focus();

                    lblKind.Text = "Loại xe: " + detail.Vehicle.Tariff.Text;
                    lblGroup.Text = "Nhóm xe: " + detail.Vehicle.Tariff.Group.Text;
                    lblHalfDay.Text = "Nửa ngày:";
                    lblFullDay.Text = "Một ngày:";

                    lblArrears.Text = null;
                    lblTested.Text = null;
                }

                lblNumber.Text = detail.Vehicle.Code;
                lblSeats.Text = seat.ToString("#,0");
                lblBeds.Text = bed.ToString("#,0");

                lblDateIn.Text = detail.DateIn.ToString("dd/MM/yyyy HH:mm:ss");
                lblDateOut.Text = detail.DateOut.Value.ToString("dd/MM/yyyy HH:mm:ss");

                lblPrice1.Text = detail.Price1.ToString("#,0");
                lblRose1.Text = detail.Rose1.ToString("#,0");

                lblPrice2.Text = detail.Price2.ToString("#,0");
                lblRose2.Text = detail.Rose2.ToString("#,0");
                lblMoney.Text = (detail.Repair ? "PHÍ ĐẬU ĐÊM " : "LỆ PHÍ ")
                    + (detail.Money == 0 ? "0đ" : detail.Money.ToString("#,0đ"));

                var total = detail.Money + arrears;
                lblTotal.Text = total.ToString("PHẢI THU #,0đ");

                var d = detail.DateOut.Value - detail.DateIn;
                lblDeposit.Text = String.Format("Lưu đậu tại bến: {0}ngày {1}giờ {2}phút {3}giây",
                    d.Days, d.Hours, d.Minutes, d.Seconds);

                lblUserIn.Text = "Cho vào: " + detail.UserIn.Name;
                lblPhone.Text = "Số ĐT: " + detail.UserIn.Phone;

                var note = (detail.Repair ? Global.STR_TEMP_OUT : "")
                                  + (detail.Show ? "" : ", " + Global.STR_NOT_VALUE)
                                  + (detail.Note == null ? "" : ", " + detail.Note);
                if (detail.Vehicle.More.ToInt32() > 0)
                    note += String.Format("Xe thu khoán {0} ghế", seat);
                if (detail.Text + "" == Global.STR_ARREAR)
                    note += detail.Text;

                note = note.Replace(", ", "").Trim();
                lblNote.Text = note;

                if (isOut)
                {
                    PerformRefresh();

                    // In phiếu thu xe cố định (trừ xe tạm ra bến)
                    if (_isFixed && !detail.Repair)
                    {
                        var rpt = new Report.Rpt_Receipt();
                        var tbl = new Station.DataSet.Dts_Fixed.ReceiptDataTable();
                        var dtr = tbl.NewRow();

                        rpt.parUnit.Value = Global.Title2;
                        rpt.parAddress.Value = Global.Address;

                        dtr["Seri"] = String.Format("{0}/{1}", detail.Order, Global.Session.Current.Month);
                        dtr["Date"] = Global.Session.Current;
                        dtr["Number"] = detail.Vehicle.Code;
                        dtr["Transport"] = detail.Vehicle.Transport.Text;

                        dtr["CostDescript"] = String.Format("{0:#,0} x {1} + {2:#,0} x {3} = ",
                            detail.Price1, seat, detail.Price2, bed);
                        dtr["RoseDescript"] = String.Format("{0:#,0} x {1} + {2:#,0} x {3} = ",
                            detail.Rose1, (seat < 1 ? 1 : seat - 1), detail.Rose2, bed);

                        dtr["Cost"] = cost;
                        dtr["Rose"] = rose;

                        dtr["ArrearsDescript"] = String.Format("({0:#,0} + {1:#,0}) x {2} = ",
                            cost, rose, detail.Arrears ?? 0);

                        dtr["Arrears"] = arrears;
                        dtr["Money"] = total;

                        dtr["Parked"] = detail.Parked;
                        dtr["ByChar"] = total.ToVietnamese("đồng");
                        dtr["Creator"] = Global.Session.User.Name;
                        dtr["Tariff"] = detail.Vehicle.Tariff.Text;
                        dtr["Note"] = note.IsNullOrEmpty() ? "" : String.Format("({0})", note.ToUpperFirst());

                        tbl.Rows.Add(dtr);
                        rpt.DataSource = tbl;

                        try { rpt.Print(); }
                        catch
                        {
                            XtraMessageBox.Show("LỖI: MÁY KHÔNG IN ĐƯỢC!",
                                Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                    }
                }

                if (_isFixed && detail.More.IsNullOrEmpty()
                    && detail.Text + "" != Global.STR_ARREAR)
                {
                    cmdOut.Enabled = false;
                    cmdTariff.Enabled = false;
                    lblTested.Text = "CHƯA KIỂM TRA";
                }
                else
                {
                    cmdOut.Enabled = true;
                    cmdTariff.Enabled = true;
                }
            }
            catch (Exception ex)
            {
                XtraMessageBox.Show("Lỗi tính tiền;" + ex.Message, Text);
            }
        }