Пример #1
0
        private void LoadData()
        {
            if (_Code == 0)
            {
                txtIssuDate.Date     = (new JDataBase()).GetCurrentDateTime();
                grdReport.DataSource = JAUTDocumentDetails.GetBusCredit();

                grdReport.gridEX1.AllowEdit = Janus.Windows.GridEX.InheritableBoolean.True;
                grdReport.gridEX1.CurrentTable.Columns["AccountNo"].EditType  = Janus.Windows.GridEX.EditType.NoEdit;
                grdReport.gridEX1.CurrentTable.Columns["OwnerPCode"].EditType = Janus.Windows.GridEX.EditType.NoEdit;
                grdReport.gridEX1.CurrentTable.Columns["BusCode"].EditType    = Janus.Windows.GridEX.EditType.NoEdit;
                grdReport.gridEX1.CurrentTable.Columns["BusNumber"].EditType  = Janus.Windows.GridEX.EditType.NoEdit;
                grdReport.gridEX1.CurrentTable.Columns["OwnerName"].EditType  = Janus.Windows.GridEX.EditType.NoEdit;
                grdReport.gridEX1.CurrentTable.Columns["TotalPrice"].EditType = Janus.Windows.GridEX.EditType.NoEdit;
            }
            else
            {
                JAUTPayment payment = new JAUTPayment(null, _Code);
                txtDesc.Text                = payment.Description;
                txtIssuDate.Date            = payment.PaymentDate;
                grdReport.DataSource        = JAUTPaymentDetails.GetData(_Code);
                grdReport.gridEX1.AllowEdit = Janus.Windows.GridEX.InheritableBoolean.False;
                DisableAll();
            }
            CalcSum();
        }
Пример #2
0
        private void btnPayment_Click(object sender, EventArgs e)
        {
            #region Validate

            if (txtDesc.Text.Trim() == "")
            {
                JMessages.Error("لطفا شرح پرداخت را وارد کنید.", "");
                return;
            }
            if (grdReport.DataSource == null ||
                grdReport.gridEX1.CurrentTable.Columns["OwnerPCode"].EditType != Janus.Windows.GridEX.EditType.NoEdit ||
                grdReport.gridEX1.CurrentTable.Columns["AccountNo"].EditType != Janus.Windows.GridEX.EditType.NoEdit ||
                grdReport.gridEX1.CurrentTable.Columns["BusCode"].EditType != Janus.Windows.GridEX.EditType.NoEdit ||
                grdReport.gridEX1.CurrentTable.Columns["BusNumber"].EditType != Janus.Windows.GridEX.EditType.NoEdit ||
                grdReport.gridEX1.CurrentTable.Columns["OwnerName"].EditType != Janus.Windows.GridEX.EditType.NoEdit ||
                grdReport.gridEX1.CurrentTable.Columns["TotalPrice"].EditType != Janus.Windows.GridEX.EditType.NoEdit)
            {
                JMessages.Error("ثبت قابل انجام نمیباشد.", "");
                return;
            }
            if (grdReport.DataSource.Rows.Count == 0)
            {
                JMessages.Error("هیچ تراکنشی برای پرداخت ثبت نشده است.", "");
                return;
            }
            #endregion Validate

            if (JMessages.Question("آیا میخواهید پرداخت انجام شود؟", "پرداخت") == System.Windows.Forms.DialogResult.Yes)
            {
                JDataBase db = new JDataBase();
                try
                {
                    #region Save Payment
                    JAUTPayment payment = new JAUTPayment(db, _Code);
                    payment.Description         = txtDesc.Text;
                    payment.PaymentDate         = txtIssuDate.Date;
                    payment.Register_Full_Title = JMainFrame.CurrentPostTitle;
                    payment.Register_Post_Code  = JMainFrame.CurrentPostCode;
                    payment.Register_User_Code  = JMainFrame.CurrentUserCode;
                    db.beginTransaction("SavePayment");
                    if (_Code > 0)
                    {
                        payment.Update(db);
                    }
                    else
                    {
                        _Code = payment.Insert(db, false);
                        if (_Code == 0)
                        {
                            throw new Exception();
                        }
                    }

                    #endregion Save

                    #region Save Details

                    DataTable SelectedOwners = grdReport.DataSource;
                    foreach (DataRow row in SelectedOwners.Rows)
                    {
                        JAUTPaymentDetail detail = new JAUTPaymentDetail();
                        detail.PaymentCode  = _Code;
                        detail.BusCode      = Convert.ToInt32(row["BusCode"]);
                        detail.OwnerPCode   = Convert.ToInt32(row["OwnerPCode"]);
                        detail.PaymentPrice = Convert.ToDecimal(row["PaymentPrice"]);
                        detail.TotalPrice   = Convert.ToDecimal(row["TotalPrice"]);
                        if (detail.Insert(db) == 0)
                        {
                            throw new Exception();
                        }
                    }
                    db.Commit();
                    if (JMessages.Question("پرداخت با موفقیت انجام شد. آیا میخواهید فایل خروجی را دریافت کنید؟", "") == System.Windows.Forms.DialogResult.Yes)
                    {
                        btnGetFile.PerformClick();
                    }
                    DisableAll();
                    #endregion Details
                }
                catch (Exception ex)
                {
                    db.Rollback("SavePayment");
                    JMessages.Error("عملیات ثبت با مشکل مواجه شده است.", "");
                }
                finally
                {
                    db.Dispose();
                }
            }
        }