private void btnInclude_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                string resultDlg = GetPathAttach();

                if (!string.IsNullOrEmpty(resultDlg))
                {
                    CS_CustQuotasCompAttach attach = new CS_CustQuotasCompAttach();
                    attach.Attatchment      = resultDlg;
                    attach.CustQuotasCompId = Convert.ToInt32(_window.lblCustQuotaId.Content);
                    listAttach.Add(attach);
                    if (_window.AttachMap.Count == 0)
                    {
                        _window.AttachMap.Add(Convert.ToInt32(_window.lblCustQuotaId.Content), listAttach);
                    }
                    else
                    {
                        _window.AttachMap[Convert.ToInt32(_window.lblCustQuotaId.Content)] = listAttach;
                    }
                    FillListView();
                }
                else
                {
                    MessageBox.Show("Nenhum arquivo selecionado!", "Aviso", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Erro ao carregar arquivo! descrição do erro: " + ex.Message, "Erro", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #2
0
        public void SaveOrUpdateAttachToSimulation(CS_CustQuotasCompAttach attach)
        {
            try
            {
                if (ExistAttachDataToSave(attach))
                {
                    attach.TBModified   = DateTime.Now;
                    attach.TBModifiedID = attach.CustQuotasCompId;
                    _context.CS_CustQuotasCompAttach.AddOrUpdate(attach);
                }
                else
                {
                    attach.Line         = GetMaxLine();
                    attach.TBCreated    = DateTime.Now;
                    attach.TBModified   = DateTime.Now;
                    attach.TBCreatedID  = attach.CustQuotasCompId;
                    attach.TBModifiedID = attach.CustQuotasCompId;
                    _context.CS_CustQuotasCompAttach.Add(attach);
                }

                _context.SaveChanges();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 private void btnClear_Click(object sender, RoutedEventArgs e)
 {
     if (lvAttach.SelectedItems.Count > 0)
     {
         CS_CustQuotasCompAttach attach = lvAttach.SelectedItem as CS_CustQuotasCompAttach;
         if (attach != null && listAttach.Count > 0)
         {
             listAttach.RemoveAll(x => x.Attatchment == attach.Attatchment);
             FillListView();
         }
     }
 }
 private void lvAttach_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     try
     {
         if (lvAttach.SelectedItems.Count > 0)
         {
             CS_CustQuotasCompAttach attach = lvAttach.SelectedItem as CS_CustQuotasCompAttach;
             if (attach != null)
             {
                 System.Diagnostics.Process.Start(attach.Attatchment);
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Beispiel #5
0
 private bool ExistAttachDataToSave(CS_CustQuotasCompAttach attach)
 {
     try
     {
         if (_context.CS_CustQuotasCompAttach.Any(x => x.CustQuotasCompId == attach.CustQuotasCompId && x.Line == attach.Line))
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }