Пример #1
0
        private void BtnSendResponse_Click(object sender, EventArgs e)
        {
            if (!string.IsNullOrWhiteSpace(meResponseBody.Text))
            {
                try
                {
                    var focusedMail  = wevMails.GetFocusedRow() as TheMail;
                    var responseMail = new TheMail();
                    responseMail.Body              = meResponseBody.Text;
                    responseMail.FromAddress       = focusedMail.ToAddress;
                    responseMail.FromDisplayName   = $"ФрэдроКлиент";
                    responseMail.ToAddress         = focusedMail.FromAddress;
                    responseMail.ToDisplayName     = focusedMail.FromDisplayName;
                    responseMail.Subject           = focusedMail.Subject;
                    responseMail.ChachedEmailBoxId = focusedMail.ChachedEmailBoxId;

                    _model.SendMail(responseMail);

                    TwinkleMessageBox.ShowSucces("Письмо отправлено!");

                    meResponseBody.Text = "";
                    SetResponseBodyVisibility(false);
                }
                catch (Exception ex)
                {
                    TwinkleMessageBox.ShowError($"Ответ не отправлен! {ex.Message}");
                }
            }
            else
            {
                TwinkleMessageBox.ShowError("Нельзя отправить пустой ответ!");
            }
        }
Пример #2
0
 public frmMain(TwinkleBaseXtraForm splashScreenForm, Credentials creds)
 {
     InitializeComponent();
     _dragger     = new FormDragger();
     _sliderAgent = new SlidePanelAgent(ucUserInfo.Width);
     try
     {
         //throw new ServerException("Huesos, axaxa!");
         _mainModel = new MainModel();
         ucMails.Init(_mainModel.BOServiceClient, creds);
         ucScheduler.Init(_mainModel.BOServiceClient);
     }
     catch (ServerException ex)
     {
         TwinkleMessageBox.ShowError(ex.Message);
         Load += (s, e) => Close();
         return;
     }
     finally
     {
         splashScreenForm?.Invoke(new Action(() => splashScreenForm.Close()));
         splashScreenForm?.Dispose();
     }
     InitEvents();
     InitStatusStrip();
 }
Пример #3
0
 public void UpdateMail(TheMail mail)
 {
     try
     {
         ServiceClient.UpdateMail(mail);
     }
     catch (FaultException ex)
     {
         TwinkleMessageBox.ShowError(ex.Message);
         ServiceClient.Abort();
     }
 }
Пример #4
0
 public void CancelAppointment(int appointmentId)
 {
     try
     {
         _schedulerServiceClient.CancelAppointment(appointmentId);
     }
     catch (FaultException ex)
     {
         TwinkleMessageBox.ShowError(ex.Message);
         _schedulerServiceClient.Abort();
     }
 }
Пример #5
0
 public void AssignAppointment(int appointmentId, int resourceId)
 {
     try
     {
         _schedulerServiceClient.AssignAppointment(appointmentId, resourceId);
     }
     catch (FaultException ex)
     {
         TwinkleMessageBox.ShowError(ex.Message);
         _schedulerServiceClient.Abort();
     }
 }
Пример #6
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         _customerModel.Save();
         TwinkleMessageBox.ShowSucces("Заказчик успешно сохранен!");
         DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         TwinkleMessageBox.ShowError($"Заказчик не сохранен! {ex.Message}");
     }
 }
Пример #7
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         _performerModel.Save();
         TwinkleMessageBox.ShowSucces("Исполнитель успешно сохранен!");
         DialogResult = DialogResult.OK;
     }
     catch (Exception ex)
     {
         TwinkleMessageBox.ShowError($"Исполнитель не сохранен! {ex.Message}");
     }
 }
Пример #8
0
 //ToDo: to add async
 private void btnSave_Click(object sender, EventArgs e)
 {
     try
     {
         _dealModel.Save();
         TwinkleMessageBox.ShowSucces("Заяка(сделка) успешно сохранена!");
         Close();
     }
     catch (Exception ex)
     {
         TwinkleMessageBox.ShowError($"Заяка(сделка) не сохранена! {ex.Message}");
     }
 }
Пример #9
0
 public Deal GetDeal(int id)
 {
     try
     {
         return(BOServiceClient.GetDeal(id));
     }
     catch (FaultException ex)
     {
         TwinkleMessageBox.ShowError(ex.Message);
         BOServiceClient.Abort();
         return(null);
     }
 }
Пример #10
0
 private void LoadResources()
 {
     try
     {
         Resources.Clear();
         var resources = _schedulerServiceClient.GetResources();
         Resources.AddRange(resources);
     }
     catch (FaultException ex)
     {
         TwinkleMessageBox.ShowError(ex.Message);
         _schedulerServiceClient.Abort();
     }
 }
Пример #11
0
 private void ShowDealForm(Deal deal)
 {
     if (deal == null)
     {
         TwinkleMessageBox.ShowError("Зделка не может быть null");
         return;
     }
     else
     {
         using (var frm = new frmDeal(_model.BOServiceClient, deal))
         {
             frm.ShowDialog();
         }
     }
 }
Пример #12
0
 public frmMails(TwinkleBaseXtraForm splashScreenForm, Credentials creds)
 {
     try
     {
         //throw new Exception("Huesos, axaxa!");
         InitializeComponent();
         //ucMails.Init(creds);
         InitEvents();
     }
     catch (ServerException ex)
     {
         TwinkleMessageBox.ShowError(ex.Message);
     }
     finally
     {
         splashScreenForm?.Invoke(new Action(() => splashScreenForm.Close()));
         splashScreenForm?.Dispose();
     }
 }
Пример #13
0
        private void BtnSend_Click(object sender, EventArgs e)
        {
            if (_model.FromEmailBoxId.HasValue && !string.IsNullOrWhiteSpace(meBody.Text))
            {
                try
                {
                    sleFrom.ErrorText = string.Empty;
                    var responseMail = new TheMail();
                    responseMail.Body              = meBody.Text;
                    responseMail.FromAddress       = _model.FromEmailBoxAddress;
                    responseMail.FromDisplayName   = "ФрэдроКлиент";
                    responseMail.ToAddress         = teTo.Text;
                    responseMail.Subject           = teSubject.Text;
                    responseMail.ChachedEmailBoxId = _model.FromEmailBoxId;

                    _model.SendMail(responseMail);

                    TwinkleMessageBox.ShowSucces("Письмо отправлено!");
                }
                catch (Exception ex)
                {
                    TwinkleMessageBox.ShowError($"Письмо не отправлено! {ex.Message}");
                }
                finally
                {
                    Close();
                }
            }
            else if (!_model.FromEmailBoxId.HasValue)
            {
                sleFrom.ErrorText = "Ошибка. Необходимо указать почтовый адрес, с которого будет отправлено письмо.";
            }
            else
            {
                TwinkleMessageBox.ShowError("Нельзя отправить пустое сообщение!");
            }
        }
Пример #14
0
 public void Init(BusinessObjectServiceClient boServiceClient, Credentials creds)
 {
     try
     {
         if (!_isInit)
         {
             _model           = new MailModel(creds);
             _boServiceClient = boServiceClient;
             InitEvents();
             SetMailButtonsVisibility(false);
             SetResponseBodyVisibility(false);
             _model.JoinToServer();
             _isInit = true;
         }
     }
     catch (ServerException ex)
     {
         throw ex;
     }
     catch (Exception ex)
     {
         TwinkleMessageBox.ShowError(ex.Message);
     }
 }
Пример #15
0
 private void SchedulerMain_AppointmentDrop(object sender, AppointmentDragEventArgs e)
 {
     try
     {
         if (e.EditedAppointment.ResourceId is EmptyResource || Convert.ToInt32(e.EditedAppointment.ResourceId) <= 0)
         {
             TwinkleMessageBox.ShowError("Заяка не будет назначена: выбран пустой ресурс(ТС)");
             e.Allow = false;
             return;
         }
         var start = e.SourceAppointment.Start;
         if (start <= DateTime.Now)
         {
             TwinkleMessageBox.ShowError("Заяка не будет назначена: невозможно назначить заяку на прошедшее время");
             e.Allow = false;
             return;
         }
         var end       = e.SourceAppointment.End;
         var vehicleId = Convert.ToInt32(e.EditedAppointment.ResourceId);
         if (CheckIfResourceIsBusy(vehicleId, start, end))
         {
             TwinkleMessageBox.ShowError("Заяка не будет назначена: выбранный ресурс(ТС) занят");
             e.Allow = false;
             return;
         }
         var sourceDealId = e.SourceAppointment.Id;
         if (sourceDealId == null)
         {
             var dealId = e.SourceAppointment.CustomFields["Id"];
             _model.AssignAppointment((int)dealId, vehicleId);
             //-->
             //using (var db = new TwinkleDbContext())
             //{
             //    deal = await db.Deals.FindAsync(dealId);
             //    deal.VehicleId = vehicleId;
             //    await db.SaveChangesAsync();
             //}
             //<--
         }
         else
         {
             var dealId = sourceDealId;
             _model.AssignAppointment((int)dealId, vehicleId);
             //-->
             //using (var db = new TwinkleDbContext())
             //{
             //    deal = await db.Deals.FindAsync(dealId);
             //    deal.VehicleId = vehicleId;
             //    await db.SaveChangesAsync();
             //}
             //<--
         }
         e.Allow = true;
         schedulerMain.BeginUpdate();
         schedulerMain.GoToDate(start.Date.AddHours(schedulerMain.Start.Hour));
         //RefreshAppointments();
         schedulerMain.EndUpdate();
     }
     catch (Exception ex)
     {
         TwinkleMessageBox.ShowError($"Заявка не назначена: {ex.Message}");
         e.Allow = false;
     }
 }
Пример #16
0
        private void FrmMails_FormClosing(object sender, FormClosingEventArgs e)
        {
            var result = TwinkleMessageBox.ShowQuestionYesNo("Вы хотите выйти?");

            e.Cancel = (result == DialogResult.No);
        }