private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }

                if (string.IsNullOrWhiteSpace(txtCode.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("کد محصول نمی تواند خالی باشد");
                    txtCode.Focus();
                    return;
                }

                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("عنوان نمی تواند خالی باشد");
                    txtName.Focus();
                    return;
                }

                if (string.IsNullOrWhiteSpace(txtPrice.Text))
                {
                    frmNotification.PublicInfo.ShowMessage("قیمت نمی تواند خالی باشد");
                    txtPrice.Focus();
                    return;
                }


                cls.Name       = txtName.Text.Trim();
                cls.Code       = txtCode.Text.Trim();
                cls.Price      = txtPrice.Text.ParseToDecimal();
                cls.BckUpPrice = txtBackUp.Text.ParseToDecimal();
                cls.Status     = true;

                var res = await ProductBussines.SaveAsync(cls);

                if (res.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                    return;
                }
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
            }
        }
Esempio n. 2
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            try
            {
                try
                {
                    if (cls.Guid == Guid.Empty)
                    {
                        cls.Guid = Guid.NewGuid();
                    }

                    if (string.IsNullOrEmpty(txtName.Text))
                    {
                        frmNotification.PublicInfo.ShowMessage("عنوان کالا نمی تواند خالی باشد");
                        txtName.Focus();
                        return;
                    }

                    if (string.IsNullOrEmpty(txtCode.Text))
                    {
                        frmNotification.PublicInfo.ShowMessage("کد کالا نمی تواند خالی باشد");
                        txtCode.Focus();
                        return;
                    }

                    if (!await ProductBussines.CheckName(cls.Guid, txtName.Text.Trim()))
                    {
                        frmNotification.PublicInfo.ShowMessage("عنوان وارد شده تکراری است");
                        txtName.Focus();
                        return;
                    }

                    cls.Code        = txtCode.Text.Trim();
                    cls.Name        = txtName.Text.Trim();
                    cls.Description = txtDesc.Text;
                    cls.Price       = txtPrice.Text.ParseToDecimal();
                    cls.ShortDesc   = txtShortDesc.Text;
                    if (string.IsNullOrEmpty(cls.ImageName))
                    {
                        cls.ImageName = "No.png";
                    }
                    var res = await cls.SaveAsync();

                    if (res.HasError)
                    {
                        frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                        return;
                    }
                    DialogResult = DialogResult.OK;
                    frmLoading.PublicInfo.ShowForm();
                    Close();
                }
                catch (Exception exception)
                {
                    WebErrorLog.ErrorInstence.StartErrorLog(exception);
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
        }