private void Process(string action) { Cursor = Cursors.WaitCursor; int year = 0; int month = 0; try { year = int.Parse(txtYear.Text.Trim()); month = int.Parse(txtMonth.Text.Trim()); } catch (Exception) { year = 0; month = 0; } if (year == 0 || month == 0) { MessageBox.Show("Parametreler Yamuk!"); Cursor = Cursors.Arrow; } else { VERPSEntities db = new VERPSEntities(); var list = db.vwWHheaders.Where(x => x.RecYear == year && x.RecMonth == month).ToList(); if (action == "makefile") { foreach (var item in list) { vwWHheader header = (vwWHheader)item; MakeFile(@"WH_" + item.FullName.Trim() + "_" + year.ToString() + "_" + month.ToString() + ".pdf", TxtUrl.Text.Trim() + item.Id.ToString()); } MessageBox.Show("Yeah!"); Cursor = Cursors.Arrow; } else if (action == "sendemail") { if (txtEmailSubject.Text.Trim() != "" && txtEmailText.Text.Trim() != "") { foreach (var item in list) { vwWHheader header = (vwWHheader)item; string file = @"WH_" + item.FullName.Trim() + "_" + year.ToString() + "_" + month.ToString() + ".pdf"; //if (item.EmailAddress == "*****@*****.**") //{ // SendEmail(item.EmailAddress, file); //} SendEmail(item.EmailAddress, file); } MessageBox.Show("Yeah!"); Cursor = Cursors.Arrow; } else { MessageBox.Show("Please enter email subject and text!"); Cursor = Cursors.Arrow; } } } }