private void DayOverSendMail() { try { getBusiness = new CustomerBusinessLayer(); var list = getBusiness.GetAll(); List <Customer> passPaymentDateList = new List <Customer>(); List <Customer> _CustomerGridList = new List <Customer>(); getSendMailBusiness = new SendMailBusinessLayer(); //Mail data = new Mail() //{ // From = txtMailAdress.Text.ToString(), // Password = txtMailPassword.Text.ToString(), // Port = Convert.ToInt32(txtMailSmtpPort.Text.ToString()), // Subject = txtMailSubject.Text.ToString(), // Body = txtMailContent.Text.ToString(), // ToAdd = txtMailRecever.Text.ToString(), // SmtpServer = txtSmtpServer.Text.ToString(), // ShopName = txtCompanyName.Text.ToString() //}; getBusiness = new CustomerBusinessLayer(); var customerList = getBusiness.GetAll(); var mailInformation = getSendMailBusiness.GetAll(); Mail mailData = null; foreach (var item in mailInformation) { mailData = new Mail() { Body = item.Body, From = item.From, Password = item.Password, ShopName = item.ShopName, SmtpServer = item.SmtpServer, Port = item.Port, Subject = item.Subject }; } foreach (var item in customerList) { // Aslında Aşağıdaki 2. Kod satırı kullanıcı insafiyetine bırakılabilir!! if (item.PassPaymentDate < DateTime.Now && item.LastSendMailDate.AddDays(+7) < DateTime.Now) { getSendMailBusiness.MailsendCustomer(mailData, item); } } } catch (Exception ex) { MessageBox.Show("Günü geçenlere otomatik mail gönderme hatası UI " + ex.Message); } }
void FillGrid() { #region Fill Customer List getBusiness = new CustomerBusinessLayer(); var list = getBusiness.GetAll(); List <Customer> passPaymentDateList = new List <Customer>(); List <Customer> _CustomerGridList = new List <Customer>(); foreach (var item in list) { if (item.PassPaymentDate < DateTime.Now) { passPaymentDateList.Add(item); } if (item.PassPaymentDate > DateTime.Now) { _CustomerGridList.Add(item); } } lblActiveCustomer.Text = list.Count().ToString(); lblPaymentCustomer.Text = _CustomerGridList.Count().ToString(); lblPassPaymentCustomer.Text = passPaymentDateList.Count().ToString(); #endregion #region FillDevCustomerGrid grdPaymentPassDate.DataSource = passPaymentDateList; grdAllCustomers.DataSource = _CustomerGridList; //grdPassPayDateMain.DataSource = passPaymentDateList; #endregion #region Fill Administration List getAdministrationBusiness = new AdministrationBusinessLayer(); var adminList = getAdministrationBusiness.GetAll(); grdAdministration.DataSource = adminList; #endregion }