Пример #1
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }
                cls.Name     = txtName.Text.Trim();
                cls.Modified = DateTime.Now;

                res.AddReturnedValue(await cls.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ثبت نوع سند");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Пример #2
0
        private async void btnQuery_Click(object sender, System.EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (string.IsNullOrEmpty(txtQuery.Text))
                {
                    res.AddError("لطفا کوئری موردنظر را وارد نمایید");
                    return;
                }

                res.AddReturnedValue(await DataBaseUtilities.RunScript.RunAsync(this, txtQuery.Text,
                                                                                new SqlConnection(Settings.AppSettings.DefaultConnectionString)));

                if (!res.HasError)
                {
                    res.AddInformation("اجرای کوئری با موفقیت انجام شد");
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
            }
            finally
            {
                var frm = new FrmShowErrorMessage(res, "خطا در درج شهرستان");
                frm.ShowDialog(this);
                frm.Dispose();
            }
        }
Пример #3
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                res.AddReturnedValue(await SaveAsync((Guid)cmbUser.SelectedValue));
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ثبت سطوح دسترسی کاربر");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    MessageBox.Show(this, "سطوح دسترسی کاربر با موفقیت ذخیره شد", "پیغام سیستم", MessageBoxButtons.OK,
                                    MessageBoxIcon.Information, MessageBoxDefaultButton.Button1,
                                    MessageBoxOptions.RightAlign);
                }
            }
        }
Пример #4
0
        private async void btnSaveNoTemp_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (MessageBox.Show("آیا از ثبت اطلاعات اطمینان دارید؟", "پیغام سیستم", MessageBoxButtons.YesNo, MessageBoxIcon.Question) != DialogResult.Yes)
                {
                    return;
                }
                cls.IsTemp = false;
                res.AddReturnedValue(await SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ثبت قولنامه به صورت داپم");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Пример #5
0
        private async void mnuChangeTemp_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                var bu   = await ContractBussines.GetAsync(guid);

                if (bu == null)
                {
                    return;
                }
                if (!bu.IsTemp)
                {
                    frmNotification.PublicInfo.ShowMessage(
                        "وضعیت قرارداد هم اکنون بسته شده می باشد");
                    return;
                }

                if (MessageBox.Show(this,
                                    $@"آیا از اعمال تغییرات اطمینان دارید؟", "تغییر وضعیت قرارداد",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }

                bu.IsTemp = false;
                res.AddReturnedValue(await bu.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در بستن قولنامه");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }
Пример #6
0
 public static void ShowError(this Form frm, ReturnedSaveFuncInfo res, string title = "")
 {
     try
     {
         var frmError = new FrmShowErrorMessage(res, title);
         frmError.ShowDialog(frm);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
Пример #7
0
        private async void mnuDelete_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                if (MessageBox.Show(this,
                                    $@"آیا از حذف قرارداد اطمینان دارید؟", "حذف",
                                    MessageBoxButtons.YesNo,
                                    MessageBoxIcon.Question) == DialogResult.No)
                {
                    return;
                }
                var prd = await ContractBussines.GetAsync(guid);

                if (!prd.IsTemp)
                {
                    frmNotification.PublicInfo.ShowMessage(
                        "شما مجاز به حذف داده نهایی شده نمی باشید");
                    return;
                }

                res.AddReturnedValue(await prd.RemoveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در حذف قولنامه");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }
Пример #8
0
 public static void ShowWarning(this UserControl frm, string message, string title = "")
 {
     try
     {
         var res = new ReturnedSaveFuncInfo();
         res.AddWarning(message);
         var frmError = new FrmShowErrorMessage(res, title);
         frmError.ShowDialog(frm);
     }
     catch (Exception ex)
     {
         WebErrorLog.ErrorInstence.StartErrorLog(ex);
     }
 }
Пример #9
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (groupBundingSource.Count <= 0)
                {
                    res.AddError("گروه نمی تواند خالی باشد");
                    cmbGroup.Focus();
                }

                cls.GroupGuid = (Guid)cmbGroup.SelectedValue;


                res.AddReturnedValue(await cls.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ارتباط شخص به گروه");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Пример #10
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }

                cls.Owner    = txtOwner.Text.Trim();
                cls.Number   = txtNumber.Text.FixString().Trim().ParseToLong();
                cls.Operator = cmbOperator.Text;

                res.AddReturnedValue(await cls.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ثبت سیمکارت");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
        private async void mnuDelete_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (DGrid.RowCount <= 0)
                {
                    return;
                }
                if (DGrid.CurrentRow == null)
                {
                    return;
                }
                var guid = (Guid)DGrid[dgGuid.Index, DGrid.CurrentRow.Index].Value;
                if (_st)
                {
                    if (MessageBox.Show(this,
                                        $@"آیا از حذف {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟", "حذف",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    var prd = await RentalAuthorityBussines.GetAsync(guid);

                    res.AddReturnedValue(await prd.ChangeStatusAsync(false));
                }
                else
                {
                    if (MessageBox.Show(this,
                                        $@"آیا از فعال کردن {DGrid[dgName.Index, DGrid.CurrentRow.Index].Value} اطمینان دارید؟",
                                        "حذف",
                                        MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Question) == DialogResult.No)
                    {
                        return;
                    }
                    var prd = await RentalAuthorityBussines.GetAsync(guid);

                    res.AddReturnedValue(await prd.ChangeStatusAsync(true));
                }
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در تغییر وضعیت ارجحیت اجاره");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    await LoadDataAsync(txtSearch.Text);
                }
            }
        }
Пример #12
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var isSendSms = false;
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid  = Guid.NewGuid();
                    isSendSms = true;
                }

                cls.AskerGuid = asker?.Guid ?? Guid.Empty;
                cls.UserGuid  = (Guid)cmbUser.SelectedValue;
                cls.Modified  = DateTime.Now;

                cls.SellPrice1  = txtSellPrice1.TextDecimal;
                cls.SellPrice2  = txtSellPrice2.TextDecimal;
                cls.RahnPrice1  = txtRahn1.TextDecimal;
                cls.RahnPrice2  = txtRahn2.TextDecimal;
                cls.EjarePrice1 = txtEjare1.TextDecimal;
                cls.EjarePrice2 = txtEjare2.TextDecimal;

                cls.HasVam                  = chbHasVam.Checked;
                cls.PeopleCount             = txtPeopleCount.Text.ParseToShort();
                cls.HasOwner                = chbHasOwner.Checked;
                cls.ShortDate               = chbShortDate.Checked;
                cls.RentalAutorityGuid      = (Guid?)cmbRentalAuthority.SelectedValue ?? Guid.Empty;
                cls.CityGuid                = (Guid)cmbCity.SelectedValue;
                cls.BuildingTypeGuid        = (Guid)cmbBuildingType.SelectedValue;
                cls.Masahat1                = txtMasahat1.Text.ParseToInt();
                cls.Masahat2                = txtMasahat2.Text.ParseToInt();
                cls.RoomCount               = txtRoomCount.Text.ParseToInt();
                cls.BuildingAccountTypeGuid = (Guid)cmbBuildingAccountType.SelectedValue;
                cls.BuildingConditionGuid   = (Guid)cmbBuildingCondition.SelectedValue;
                cls.ShortDesc               = txtDesc.Text;

                await SetRegionsAsync(cls.Guid);

                res.AddReturnedValue(await cls.SaveAsync());

                if (res.HasError)
                {
                    return;
                }

                if (Settings.Classes.Payamak.IsSendToSayer.ParseToBoolean() && isSendSms)
                {
                    _ = Task.Run(() => Payamak.FixSms.RequestSend.SendAsync(cls));
                }

                if (MessageBox.Show("آیا مایلید املاک مطابق با این تقاضا را مشاهده نمایید؟", "تطبیق املاک با تقاضا",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                {
                    return;
                }

                var list = new List <BuildingViewModel>();

                decimal       fPrice1, fPrice2, sPrice1, sPrice2;
                EnRequestType type;

                if (cls.SellPrice1 > 0 || cls.SellPrice2 > 0)
                {
                    type    = EnRequestType.Forush;
                    fPrice1 = cls.SellPrice1;
                    fPrice2 = cls.SellPrice2;
                    sPrice1 = sPrice2 = 0;
                }
                else
                {
                    type    = EnRequestType.Rahn;
                    fPrice1 = cls.RahnPrice1;
                    fPrice2 = cls.RahnPrice2;
                    sPrice1 = cls.EjarePrice1;
                    sPrice2 = cls.EjarePrice2;
                }

                _token?.Cancel();
                _token = new CancellationTokenSource();
                list.AddRange(await BuildingBussines.GetAllAsync(null, _token.Token, Guid.Empty,
                                                                 cls.BuildingAccountTypeGuid, cls.Masahat1,
                                                                 cls.Masahat2, cls.RoomCount, fPrice1,
                                                                 sPrice1, fPrice2,
                                                                 sPrice2, type, cls.RegionList?.Select(q => q.RegionGuid).ToList()));

                if (list.Count <= 0)
                {
                    MessageBox.Show("متاسفانه در حال حاضر، ملکی مطابق با این تقاضا وجود ندارد");
                    return;
                }

                var frm = new frmBuildingAdvanceSearch(list);
                frm.ShowDialog(this);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ثبت تقاضا");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                var isSendSms = false;
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid  = Guid.NewGuid();
                    isSendSms = true;
                }

                res.AddReturnedValue(await SetObjectAsync());
                if (res.HasError)
                {
                    return;
                }

                res.AddReturnedValue(await SetOptionsAsync(cls.Guid));
                if (res.HasError)
                {
                    return;
                }

                res.AddReturnedValue(await cls.SaveAsync());
                if (res.HasError)
                {
                    return;
                }


                if (!Settings.Classes.Payamak.IsSendToOwner.ParseToBoolean() || !isSendSms)
                {
                    return;
                }
                var tr = await Payamak.FixSms.OwnerSend.SendAsync(cls);

                frmNotification.PublicInfo.ShowMessage(tr.HasError
                    ? tr.ErrorMessage
                    : "ارسال پیامک به مالک با موفقیت انجام شد");

                if (res.HasError)
                {
                    return;
                }

                if (MessageBox.Show("آیا مایلید تقاضاهای مطابق با این ملک را مشاهده نمایید؟", "تطبیق املاک با تقاضا",
                                    MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                {
                    return;
                }
                _token?.Cancel();
                _token = new CancellationTokenSource();
                var list = await BuildingRequestViewModel.GetAllMatchesItemsAsync(cls, _token.Token);

                if (list.Count <= 0)
                {
                    MessageBox.Show("فایل مطابقی جهت نمایش وجود ندارد");
                    return;
                }

                new frmShowRequestMatches(list).ShowDialog(this);
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ذخیره سازی ملک");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Пример #14
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }

                if (string.IsNullOrWhiteSpace(txtPass1.Text))
                {
                    res.AddError("کلمه عبور نمی تواند خالی باشد");
                    txtPass1.Focus();
                }

                if (string.IsNullOrWhiteSpace(txtPass2.Text))
                {
                    res.AddError("تکرار کلمه عبور نمی تواند خالی باشد");
                    txtPass2.Focus();
                }

                if (txtPass1.Text != txtPass2.Text)
                {
                    res.AddError("کلمه عبور با تکرار آن همخوانی ندارد");
                    txtPass1.Focus();
                }

                if (res.HasError)
                {
                    return;
                }
                var ue        = new UTF8Encoding();
                var bytes     = ue.GetBytes(txtPass1.Text.Trim());
                var md5       = new MD5CryptoServiceProvider();
                var hashBytes = md5.ComputeHash(bytes);
                cls.Password = System.Text.RegularExpressions.Regex.Replace(BitConverter.ToString(hashBytes), "-", "")
                               .ToLower();

                res.AddReturnedValue(await cls.SaveAsync());
                if (res.HasError)
                {
                    frmNotification.PublicInfo.ShowMessage(res.ErrorMessage);
                    return;
                }

                var text = $"کاربر گرامی: {cls?.Name} عزیز " +
                           $"\r\n در تاریخ {Calendar.MiladiToShamsi(DateTime.Now)} رمز ورود به سیستم شما تعویض شد" +
                           $"\r\n گروه مهندسی آراد";

                if (_type != 0)
                {
                    return;
                }
                if (string.IsNullOrEmpty(Settings.Classes.Payamak.DefaultPanelGuid))
                {
                    return;
                }

                var panel = SmsPanelsBussines.Get(Guid.Parse(Settings.Classes.Payamak.DefaultPanelGuid));
                if (panel == null)
                {
                    return;
                }

                var sApi = new Sms.Api(panel.API.Trim());


                var result = sApi.Send(panel.Sender, cls?.Mobile ?? "", text);

                var smsLog = new SmsLogBussines()
                {
                    Guid       = Guid.NewGuid(),
                    UserGuid   = cls?.Guid ?? Guid.Empty,
                    Cost       = result.Cost,
                    Message    = result.Message,
                    MessageId  = result.Messageid,
                    Reciver    = result.Receptor,
                    Sender     = result.Sender,
                    StatusText = result.StatusText
                };

                res.AddReturnedValue(await smsLog.SaveAsync());
            }
            catch (Exception exception)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(exception);
                res.AddReturnedValue(exception);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ثبت رمز عبور کاربر");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }
Пример #15
0
        private async void btnFinish_Click(object sender, EventArgs e)
        {
            var res = new ReturnedSaveFuncInfo();

            try
            {
                if (string.IsNullOrWhiteSpace(txtName.Text))
                {
                    res.AddError("عنوان گروه نمی تواند خالی باشد");
                    txtName.Focus();
                }

                if (!await PeopleGroupBussines.CheckNameAsync(txtName.Text, cls.Guid))
                {
                    var pg = await PeopleGroupBussines.GetAsync(txtName.Text);

                    if (pg.Status)
                    {
                        res.AddError("عنوان گروه تکراری است");
                        txtName.Focus();
                    }
                    else
                    {
                        pg.ParentGuid = (Guid)cmbGroup.SelectedValue;
                        pg.Status     = true;
                        cls.Modified  = DateTime.Now;
                        var res2 = await cls.SaveAsync();

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

                    return;
                }

                if (cls.Guid == Guid.Empty)
                {
                    cls.Guid = Guid.NewGuid();
                }
                cls.Name       = txtName.Text;
                cls.Modified   = DateTime.Now;
                cls.ParentGuid = (Guid)cmbGroup.SelectedValue;

                res.AddReturnedValue(await cls.SaveAsync());
            }
            catch (Exception ex)
            {
                WebErrorLog.ErrorInstence.StartErrorLog(ex);
                res.AddReturnedValue(ex);
            }
            finally
            {
                if (res.HasError)
                {
                    var frm = new FrmShowErrorMessage(res, "خطا در ثبت گروه اشخاص");
                    frm.ShowDialog(this);
                    frm.Dispose();
                }
                else
                {
                    DialogResult = DialogResult.OK;
                    Close();
                }
            }
        }