private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid     = Guid.NewGuid();
                    cls.DateM    = DateTime.Now;
                    cls.UserGuid = UserBussines.CurrentUser.Guid;
                }

                cls.Modified    = DateTime.Now;
                cls.Number      = (long)txtNumber.Value;
                cls.Description = txtDesc.Text;
                cls.TafsilGuid  = _tafsilGuid;
                cls.SanadNumber = (long)txtSanadNo.Value;

                res.AddReturnedValue(await cls.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    this.ShowError(res, "خطا در ثبت برگه دریافت");
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Esempio n. 2
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("طرف حساب نمی تواند خالی باشد");
                    txtName.Focus();
                    return;
                }

                if (txtNaqdPrice.Text == "0" && txtBankPrice.Text == "0" && txtCheckPrice.Text == "0")
                {
                    frmNotification.PublicInfo.ShowMessage("لطفا یکی از فیلدهای مبلغ را وارد نمایید");
                    return;
                }

                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }
                cls.BankName    = txtBankName.Text;
                cls.CheckNo     = txtCheckNo.Text;
                cls.Description = txtDesc.Text;
                cls.FishNo      = txtFishNo.Text;
                cls.SarResid    = txtSarResid.Text;
                cls.NaqdPrice   = txtNaqdPrice.Text.ParseToDecimal();

                if (cmbNaqd.SelectedValue != null)
                {
                    cls.NaqdSafeBoxGuid = (Guid)cmbNaqd.SelectedValue;
                }
                else
                {
                    cls.NaqdSafeBoxGuid = Guid.Empty;
                }

                cls.BankPrice = txtBankPrice.Text.ParseToDecimal();

                if (cmbBank.SelectedValue != null)
                {
                    cls.BankSafeBoxGuid = (Guid)cmbBank.SelectedValue;
                }
                else
                {
                    cls.BankSafeBoxGuid = Guid.Empty;
                }

                cls.Check    = txtCheckPrice.Text.ParseToDecimal();
                cls.UserGuid = Users.CurentUser.CurrentUser.Guid;

                var res = await ReceptionBussines.SaveAsync(cls);

                if (res.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                    return;
                }

                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }