Codes That I Wrote For Ticket System:: #Code 01
Codes That I Wrote For Ticket System:: #Code 01
</title> <style type="text/css"> .style1 { width: 21%; height: 84px; } </style> <link rel="stylesheet" href="panel/images/button1/cbcscbinsmenu.css" type="text/css" /></head> <body> <form name="form1" method="post" action="giris.aspx" id="form1"> <div> <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTQ0OTIyNjMyMmQYAQUeX19Db250cm9sc1JlcXVpcmVQb3N0QmFja0tleV9f FgEFDEltYWdlQnV0dG9uMWgIcmB8pDsp+cONdM11XktmWV+2" /> </div>
<div>
<table id="cbinsmenuebul_table" width="0" cellpadding="0" cellspacing="0" border="0"> <tr> <td style="padding-right:1px" title=""> </td> </tr> </table> <script type="text/javascript" src="panel/images/button1/cbjscbinsmenu.js"></script>
</div> </form>
#Code 02:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Data; using System.Data.SqlClient;
/// <summary> /// Summary description for DAL /// </summary> public class DAL { public DAL() { }
public static SqlConnection conn = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket"); public static DataTable Baglan(string[] alanAdlari, string[] tabloAdlari, string Sart) { string alanToplam = "";
SqlCommand comm = new SqlCommand("SELECT " + alanToplam + " FROM " + tabloToplam + " " + Sart +"", conn);
try
} finally { conn.Close(); }
return dt;
#Code 03:
using System;
public partial class giris : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
string[] alanAdlari = new string[] { "PERSONEL_ID", "PERSONEL_ADI", "PERSONEL_YETKI", "PERSONEL_SIFRE","PERSONEL_BIRIM" }; string[] tabloAdlari = new string[] { "PERSONEL" };
Session["Birim"] = dt.Rows[0][4].ToString();
if (Convert.ToInt32(dt.Rows[0][3].ToString()) == 1) Response.Redirect("panel/sifreDegistir.aspx");
Response.Redirect("panel/sorunBildirim.aspx"); }
} }
#Code 04:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
public partial class panel_sorunBildirim : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
} } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { SqlConnection conn = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;initial catalog=Ticket;integrated security=sspi"); try { conn.Open(); SqlCommand idBul = new SqlCommand("SELECT PERSONEL_ID,PERSONEL_YETKI FROM PERSONEL WHERE PERSONEL.PERSONEL_ADI='" + Session["Ad"].ToString() + "'", conn); DataTable dt = new DataTable(); dt.Load(idBul.ExecuteReader());
} }
#Code 05:
Using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
protected void Page_Load(object sender, EventArgs e) { int yetki = Convert.ToInt32(Session[Yetki].ToString()); if (yetki == 0) { Response.Redirect(hata.aspx); } if (yetki == 1) { SqlConnection conn1 = new SqlConnection(@data source=GIFTED\SQLEXPRESS;initial catalog=Ticket;integrated security=sspi); SqlCommand comm1 = new SqlCommand(SELECT S.SORUN_ID AS [SORUN ID ], P.PERSONEL_ADI AS [AD SOYAD],S.ACIKLAMA AS [SORUN],SOR.KATEGORI_ADI
try {
CheckBox chbEkle = new CheckBox(); chbEkle.ID = chb + i.ToString(); grdSorun.Rows[i].Cells[0].Controls.Add(chbEkle); chbEkle.Checked = false;
} finally { conn1.Close();
try {
CheckBox chbEkle = new CheckBox(); chbEkle.ID = chb + i.ToString(); grdSorun.Rows[i].Cells[0].Controls.Add(chbEkle); chbEkle.Checked = false;
} finally { conn5.Close();
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { for (int i = 0; i < grdSorun.Rows.Count; i++) { CheckBox c = (CheckBox)grdSorun.Rows[i].Cells[0].FindControl(chb + i.ToString()); if (c.Checked) {
SqlConnection conn = new SqlConnection(@data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket); SqlCommand comm = new SqlCommand(UPDATE SORUN_TABLOSU SET ISLEM_BASLANGIC_ZAMAN= + DateTime.Now.ToString(yyyyMMddHHmm) + , ONAY_DURUM=1 WHERE SORUN_ID= + Convert.ToInt32(grdSorun.Rows[i].Cells[1].Text) + AND ONAY_DURUM=0, conn); try { conn.Open(); comm.ExecuteNonQuery();
} finally { conn.Close();
} /* else { SqlConnection conn = new SqlConnection(@data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket); SqlCommand comm = new SqlCommand(UPDATE SORUN_TABLOSU SET ISLEM_BASLANGIC_ZAMAN=, ONAY_DURUM=0 WHERE (SELECT PERSONEL_ID FROM PERSONEL WHERE PERSONEL_ADI= + grdSorun.Rows[i].Cells[2].Text.ToString() + )=PERSONEL_ID, conn); try { conn.Open(); comm.ExecuteNonQuery();
} finally { conn.Close();
} */
} Response.Redirect(gelenBildirimler.aspx); } protected void ImageButton2_Click(object sender, ImageClickEventArgs e) { for (int i = 0; i < grdSorun.Rows.Count; i++) { CheckBox c = (CheckBox)grdSorun.Rows[i].Cells[0].FindControl(chb + i.ToString()); if (c.Checked) {
int dene = Convert.ToInt32(grdSorun.Rows[i].Cells[1].Text); SqlConnection conn = new SqlConnection(@data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket);
} }
#Code 06:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
public partial class panel_bildirimler : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
SqlConnection conn1 = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;initial catalog=Ticket;integrated security=sspi"); SqlCommand comm1 = new SqlCommand("SELECT S.SORUN_ID AS [SORUN ID ],S.ACIKLAMA,DBO.FNK_TARIHI_FORMATLA(S.BASLANGIC_ZAMAN) AS [BASLANGIC ZAMANI ], DBO.FNK_TARIHI_FORMATLA(S.ISLEM_BASLANGIC_ZAMAN) AS [ISLEM BASLANGIC ZAMANI ],DBO.FNK_TARIHI_FORMATLA(S.ISLEM_BITIS_ZAMAN) AS [ISLEM BITIS ZAMANI ],DBO.FNK_TARIHI_FORMATLA(S.ONAY_ZAMAN) AS [ONAY ZAMANI
} finally { conn1.Close(); }
e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=this.originalstyle;"); } protected void grdSorun_RowDeleting(object sender, GridViewDeleteEventArgs e) { string sorunId = grdSorun.Rows[e.RowIndex].Cells[1].Text.ToString(); SqlConnection conn = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;initial catalog=Ticket;integrated security=sspi"); SqlCommand comm = new SqlCommand("UPDATE SORUN_TABLOSU SET ONAY_ZAMAN='" + DateTime.Now.ToString("yyyyMMddHHmm") + "',ONAY_DURUM=3 WHERE PERSONEL_ID=" + Convert.ToInt32(Session["Id"].ToString()) + " AND SORUN_ID=" + Convert.ToInt32(sorunId) + " AND ONAY_DURUM=2", conn); try { conn.Open(); comm.ExecuteNonQuery(); grdSorun.Rows[e.RowIndex].Visible = false;
} finally { conn.Close(); } } protected void ImageButton1_Click(object sender, ImageClickEventArgs e) { SqlConnection conn = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;initial catalog=Ticket;integrated security=sspi"); SqlCommand comm = new SqlCommand("DELETE FROM KATEGORI_LOG WHERE SORUN_ID=" + TextBox1.Text + "", conn); SqlCommand comm2 = new SqlCommand("DELETE FROM SORUN_TABLOSU WHERE SORUN_ID=" + TextBox1.Text + "", conn); try { conn.Open(); comm.ExecuteNonQuery(); comm2.ExecuteNonQuery();
#Code 07:
Using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
public partial class panel_kategoriDegistir : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { int yetki = Convert.ToInt32(Session[Yetki].ToString()); if (yetki == 0) { Response.Redirect(hata.aspx); }
if (!IsPostBack) { string[] alanAdi = new string[] { KATEGORI_ID, KATEGORI_ADI }; string[] tabloAdi = new string[] { SORUN_KATEGORI_TABLOSU };
SqlConnection conn1 = new SqlConnection(@data source=GIFTED\SQLEXPRESS;initial catalog=Ticket;integrated security=sspi); SqlCommand comm1 = new SqlCommand(SELECT S.SORUN_ID AS [SORUN ID ], P.PERSONEL_ADI AS [AD SOYAD],S.ACIKLAMA AS [SORUN],SOR.KATEGORI_ADI AS [KATEGORI ADI],DBO.FNK_TARIHI_FORMATLA(BASLANGIC_ZAMAN) AS [BASLANGIC ZAMANI ],ONAY.ONAY_DURUM AS [ONAY DURUM],DBO.FNK_TARIHI_FORMATLA(S.ISLEM_BASLANGIC_ZAMAN) AS [ISLEM BASLANGIC ZAMANI ],DBO.FNK_TARIHI_FORMATLA(S.ONAY_ZAMAN) AS [ONAY ZAMANI ],ONAY.ONAY_ACIKLAMA AS [DURUM],K.ESKI_KATEGORI AS [ESKI KATEGORI],S.YETKILI_ACIKLAMA AS [YETKILI ACIKLAMA],DBO.FNK_TARIHI_FORMATLA(K.KATEGORI_DEGISIM_ZAMAN) AS [KATEGORI DEGISIM ZAMANI],K.ACIKLAMA AS [KATEGORI DEGISIM ACIKLAMASI] FROM SORUN_TABLOSU AS S INNER JOIN PERSONEL AS P ON P.PERSONEL_ID=S.PERSONEL_ID INNER JOIN SORUN_KATEGORI_TABLOSU AS SOR ON S.KATEGORI_ID=SOR.KATEGORI_ID INNER JOIN ONAY_TABLOSU AS ONAY ON S.ONAY_DURUM=ONAY.ONAY_DURUM LEFT JOIN KATEGORI_LOG AS K ON S.SORUN_ID=K.SORUN_ID WHERE S.ONAY_DURUM=0 OR S.ONAY_DURUM=1, conn1);
try {
} finally { conn1.Close();
} protected void Button3_Click(object sender, EventArgs e) { for (int i = 0; i < grdSorun.Rows.Count; i++) {
SqlConnection conn = new SqlConnection(@data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket); SqlCommand comm = new SqlCommand(UPDATE SORUN_TABLOSU SET KATEGORI_ID= + drpKategori.SelectedValue + WHERE SORUN_ID= + Convert.ToInt32(grdSorun.Rows[i].Cells[1].Text) + , conn); try { conn.Open(); comm.ExecuteNonQuery();
} } }
//BR TANE TRIGGER YAZICAZ BU KATEGORI LOG KISMINDAKI YENI KATEGORI LE SORUN TABLOSUNDAKINI DETRECEK //EKLE KISMIYLA KATEGORI DEME SEIBEB VE YETKILI AIKLAMA EKLEYEYEBLECEK //TASARIM BUTONLARI DZELTLECEK //BU BLDRM TARAFINDAKI SEME KISMI YAPILACAK //MAIL OLAYINA BAKILACAK
SqlConnection conn = new SqlConnection(@data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket); SqlCommand comm = new SqlCommand(UPDATE SORUN_TABLOSU SET YETKILI_ACIKLAMA= + txtAciklama.Text + WHERE SORUN_ID= + Convert.ToInt32(grdSorun.Rows[i].Cells[1].Text) + , conn);
} finally {
conn.Close(); Response.Redirect(kategoriDegistir.aspx);
} } } else {
} finally { conn3.Close();
} }
} } }
#Code 08:
Using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
public partial class panel_yonetim : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e)
SqlCommand comm1 = new SqlCommand(SELECT [SORUN_ID] AS [SORUN ID ],ACIKLAMA,DBO.FNK_TARIHI_FORMATLA(BASLANGIC_ZAMAN) AS [BASLANGIC ZAMANI ], DBO.FNK_TARIHI_FORMATLA(ISLEM_BASLANGIC_ZAMAN) AS [ISLEM BASLANGIC ZAMANI ],DBO.FNK_TARIHI_FORMATLA(ISLEM_BITIS_ZAMAN) AS [ISLEM BITIS ZAMANI ],DBO.FNK_TARIHI_FORMATLA(ONAY_ZAMAN) AS [ONAY ZAMANI ],ONAY_ACIKLAMA AS DURUM FROM SORUN_TABLOSU,PERSONEL,ONAY_TABLOSU AS O WHERE PERSONEL.PERSONEL_BIRIM= + Session[Birim].ToString() + AND (SORUN_TABLOSU.ONAY_DURUM=0 OR SORUN_TABLOSU.ONAY_DURUM=1) AND PERSONEL.PERSONEL_ID=SORUN_TABLOSU.PERSONEL_ID AND O.ONAY_DURUM=SORUN_TABLOSU.ONAY_DURUM, conn1);
} finally { conn1.Close(); }
} if (yetki == 2) {
SqlCommand comm2 = new SqlCommand(SELECT [SORUN_ID] AS [SORUN ID ],ACIKLAMA,DBO.FNK_TARIHI_FORMATLA(BASLANGIC_ZAMAN) AS [BASLANGIC ZAMANI ], DBO.FNK_TARIHI_FORMATLA(ISLEM_BASLANGIC_ZAMAN) AS [ISLEM BASLANGIC ZAMANI ],DBO.FNK_TARIHI_FORMATLA(ISLEM_BITIS_ZAMAN) AS [ISLEM BITIS ZAMANI ],DBO.FNK_TARIHI_FORMATLA(ONAY_ZAMAN) AS [ONAY ZAMANI ],SOR.KATEGORI_ADI,ONAY_ACIKLAMA AS DURUM FROM SORUN_TABLOSU,PERSONEL,ONAY_TABLOSU AS O,SORUN_KATEGORI_TABLOSU SOR WHERE PERSONEL.PERSONEL_BIRIM= + Session[Birim].ToString() + AND (SORUN_TABLOSU.ONAY_DURUM=0 OR SORUN_TABLOSU.ONAY_DURUM=1) AND PERSONEL.PERSONEL_ID=SORUN_TABLOSU.PERSONEL_ID AND O.ONAY_DURUM=SORUN_TABLOSU.ONAY_DURUM AND SOR.KATEGORI_ID=SORUN_TABLOSU.KATEGORI_ID , conn1);
try { conn1.Open(); DataTable dt = new DataTable(); dt.Load(comm2.ExecuteReader()); grdSorun.DataSource = dt; grdSorun.DataBind(); } catch (Exception ex) {
} finally { conn1.Close(); } } } protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e) { if (e.Row.RowType != DataControlRowType.DataRow) return;
e.Row.Attributes.Add(onmouseout, this.style.backgroundColor=this.originalstyle;); } protected void grdSorun_RowDeleting1(object sender, GridViewDeleteEventArgs e) { string sorunId = grdSorun.Rows[e.RowIndex].Cells[1].Text.ToString(); SqlConnection conn = new SqlConnection(@data source=GIFTED\SQLEXPRESS;initial catalog=Ticket;integrated security=sspi); SqlCommand comm = new SqlCommand(UPDATE SORUN_TABLOSU SET [ONAY_ZAMAN]= + DateTime.Now.ToString(yyyyMMddhhmm) + ,[ONAY_DURUM]=3 WHERE SORUN_ID= + Convert.ToInt32(sorunId) + , conn); try { conn.Open(); comm.ExecuteNonQuery(); grdSorun.Rows[e.RowIndex].Visible = false;
#Code 09:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
public partial class panel_personelEkle : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { int yetki = Convert.ToInt32(Session["Yetki"].ToString());
SqlCommand comm = new SqlCommand("INSERT INTO PERSONEL ([PERSONEL_ID],[PERSONEL_ADI],[PERSONEL_YETKI],[PERSONEL_SIFRE],[PERSONEL_B IRIM]) VALUES (" + Convert.ToInt32(txtId.Text) + ", '" + txtAd.Text.ToUpper() + "' , 0, '" + txtSifre.Text.ToString() + "', '" + txtBirim.Text.ToUpper() + "')", conn); try { conn.Open(); comm.ExecuteNonQuery();
} finally {
} } }
#Code 10:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
protected void Calendar1_SelectionChanged(object sender, EventArgs e) { if (txtBaslangicTarih.Text == "") { txtBaslangicTarih.Text = Calendar1.SelectedDate.ToString("dd.MM.yyyy"); } else { txtBitisTarih.Text = Calendar1.SelectedDate.ToString("dd.MM.yyyy"); }
} protected void ImageButton1_Click2(object sender, ImageClickEventArgs e) { SqlConnection conn = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket"); SqlCommand comm = new SqlCommand("SELECT S.SORUN_ID AS [SORUN ID],P.PERSONEL_ADI AS PERSONEL,S.ACIKLAMA,DBO.FNK_TARIHI_FORMATLA(S.BASLANGIC_ZAMAN) AS [BASLANGIC ZAMANI],SOR.KATEGORI_ADI AS KATEGORI,DBO.FNK_TARIHI_FORMATLA(S.ISLEM_BASLANGIC_ZAMAN) AS [ISLEM BASLANGIC ZAMANI],DBO.FNK_TARIHI_FORMATLA(S.ONAY_ZAMAN) AS [ONAY ZAMANI],O.ONAY_ACIKLAMA AS DURUM,S.YETKILI_ACIKLAMA AS [YETKILI ACIKLAMA] FROM SORUN_TABLOSU AS S,SORUN_KATEGORI_TABLOSU AS SOR,PERSONEL AS P,ONAY_TABLOSU AS O WHERE S.KATEGORI_ID=SOR.KATEGORI_ID AND O.ONAY_DURUM=S.ONAY_DURUM AND P.PERSONEL_ID=S.PERSONEL_ID AND ((CONVERT (DECIMAL,BASLANGIC_ZAMAN))>=(" + Convert.ToDateTime(txtBaslangicTarih.Text).ToString("yyyyMMddHHmm") + ") AND (CONVERT (DECIMAL,ONAY_ZAMAN))<=(" + Convert.ToDateTime(txtBitisTarih.Text).ToString("yyyyMMddHHmm") + ")) ORDER BY S.BASLANGIC_ZAMAN DESC", conn); try { conn.Open(); DataTable dt = new DataTable(); dt.Load(comm.ExecuteReader());
} finally { conn.Close(); }
#Code 11:
public partial class panel_yoneticiyeBildir : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //BURAYA PERSONEL ID VE BENZERI GETIRIP MAIL ATTIRICAZ
SqlConnection conn = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket"); SqlCommand mailAl = new SqlCommand("SELECT PERSONEL_MAIL FROM PERSONEL WHERE PERSONEL_BIRIM='" + Session["Birim"] + "' AND (PERSONEL_YETKI= 1 OR PERSONEL_YETKI=2)", conn); SqlCommand comm = new SqlCommand("SELECT P.PERSONEL_ADI,P.PERSONEL_BIRIM,S.SORUN_ID,S.ACIKLAMA,DBO.FNK_TARIHI_FORMAT LA(S.BASLANGIC_ZAMAN),DBO.FNK_TARIHI_FORMATLA(S.ISLEM_BASLANGIC_ZAMAN),SOR.
try { conn.Open(); string mail = mailAl.ExecuteScalar().ToString(); dt.Load(comm.ExecuteReader()); string konu = "Bildiren Personel : " + dt.Rows[0][0].ToString() + "\n" + " Personel Birimi : " + dt.Rows[0][1].ToString() + "\n" + "Sorun Id : " + dt.Rows[0][2].ToString() + "\n" + "Aklama : " + dt.Rows[0][3].ToString() + "\n" + "Bildirim Zaman : " + dt.Rows[0][4].ToString() + "\n" + "lem Balang Zaman : " + dt.Rows[0][5].ToString() + "\n" + "Kategorisi : " + dt.Rows[0][6].ToString() + "\n" + "Onay Durumu : " + dt.Rows[0][7].ToString();
mailGonder(mail, "[email protected]", "sifre", konu, dt.Rows[0][2].ToString() + ". Id Nolu Problem - " + dt.Rows[0][1]);
private void mailGonder(string kime, string kullaniciAdi, string sifre, string konu, string baslik) { MailMessage mail = new MailMessage(); mail.From = new MailAddress(kullaniciAdi); mail.Priority = MailPriority.High; mail.To.Add(new MailAddress(kime)); mail.Body = konu; mail.Subject = baslik;
SmtpClient sc = new SmtpClient(); sc.Host = "mail.gvg.com.tr"; sc.Port = 587; sc.Credentials = sad; sc.Send(mail); } }
#Code 12:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
SqlConnection conn = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket"); SqlCommand comm = new SqlCommand("UPDATE PERSONEL SET PERSONEL_SIFRE=" + TextBox1.Text + " WHERE PERSONEL_ID="+ Convert.ToInt32(Session["Id"]) +"", conn);
try {
conn.Open(); comm.ExecuteNonQuery();
conn.Close();
#Code 13:
namespace MailAtanWindowsServis { public partial class MailAtanServis : ServiceBase { Timer Zamanlayici; SqlConnection conn;
protected override void OnStart(string[] args) { // Servisimiz start oldugu zaman zamanlayc adn verdigimiz timer nesnemizi start edelim.
void Zamanlayici_Elapsed(object sender, ElapsedEventArgs e) { //Bu ksmda veritanndan okuyan ksm yapcaz. Yani gidip kontrol edecek ve 2 saat ise mail atacak //Veritabannda bir onay duruma bakarz. Kullanc onay (0,1,2) olmamas lazm. Ayrca ilem balang zamanna 120 dk ekleriz. Hala zlmemise ///mail at.
SqlConnection conn = new SqlConnection(@"data source=GIFTED\SQLEXPRESS;integrated security=sspi;initial catalog=Ticket"); SqlCommand comm = new SqlCommand("SELECT S.ISLEM_BASLANGIC_ZAMAN,S.ONAY_DURUM,S.PERSONEL_ID,P.PERSONEL_BIRIM FROM
for (int i = 0; i < dt.Rows.Count; i++) { string personelBirim = dt.Rows[i][3].ToString(); int personelID = Convert.ToInt32(dt.Rows[i][2].ToString()); double baslangicTarih = Convert.ToDouble(dt.Rows[i][0].ToString()); //buradaki 300 3 saati temsil etmektedir. double sonTarih = baslangicTarih + 300; double sonTarih1 = baslangicTarih + 200;
if (Convert.ToDouble(DateTime.Now.ToString("yyyyMMddHHmm")) == sonTarih1) {
SqlCommand mailAl1 = new SqlCommand("SELECT PERSONEL_MAIL FROM PERSONEL WHERE PERSONEL_BIRIM='" + personelBirim + "' AND PERSONEL_YETKI= 1", conn); SqlCommand comm3 = new SqlCommand("SELECT P.PERSONEL_ADI,P.PERSONEL_BIRIM,S.SORUN_ID,S.ACIKLAMA,DBO.FNK_TARIHI_FORMAT LA(S.BASLANGIC_ZAMAN),DBO.FNK_TARIHI_FORMATLA(S.ISLEM_BASLANGIC_ZAMAN),SOR. KATEGORI_ADI,ONAY_ACIKLAMA FROM PERSONEL AS P INNER JOIN SORUN_TABLOSU AS S ON S.PERSONEL_ID=P.PERSONEL_ID INNER JOIN SORUN_KATEGORI_TABLOSU AS SOR ON S.KATEGORI_ID=SOR.KATEGORI_ID INNER JOIN ONAY_TABLOSU AS O ON O.ONAY_DURUM=S.ONAY_DURUM AND (S.ONAY_DURUM=0 OR S.ONAY_DURUM=1) AND P.PERSONEL_ID=" + personelID + "", conn); DataTable dt3 = new DataTable();
string mail1 = mailAl1.ExecuteScalar().ToString(); dt3.Load(comm3.ExecuteReader()); string konu1 = "Bildiren Personel : " + dt3.Rows[0][0].ToString() + "\n" + " Personel Birimi : " + dt3.Rows[0][1].ToString() + "\n" + "Sorun Id : " + dt3.Rows[0][2].ToString() + "\n" + "Aklama : " + dt3.Rows[0][3].ToString() + "\n" + "Bildirim Zaman : " + dt3.Rows[0][4].ToString() + "\n" + "lem Balang Zaman : " + dt3.Rows[0][5].ToString() + "\n" + "Kategorisi : " + dt3.Rows[0][6].ToString() + "\n" + "Onay Durumu : " + dt3.Rows[0][7].ToString();
mailGonder(mail1, "[email protected]", "1234", konu1, dt3.Rows[0][2].ToString() + ". Id Nolu Problem - " + dt3.Rows[0][1]);
if (Convert.ToDouble(DateTime.Now.ToString("yyyyMMddHHmm")) == sonTarih) {
SqlCommand mailAl = new SqlCommand("SELECT PERSONEL_MAIL FROM PERSONEL WHERE PERSONEL_BIRIM='" + personelBirim + "' AND PERSONEL_YETKI= 2", conn); SqlCommand comm2 = new SqlCommand("SELECT P.PERSONEL_ADI,P.PERSONEL_BIRIM,S.SORUN_ID,S.ACIKLAMA,DBO.FNK_TARIHI_FORMAT LA(S.BASLANGIC_ZAMAN),DBO.FNK_TARIHI_FORMATLA(S.ISLEM_BASLANGIC_ZAMAN),SOR. KATEGORI_ADI,ONAY_ACIKLAMA FROM PERSONEL AS P INNER JOIN SORUN_TABLOSU AS S ON S.PERSONEL_ID=P.PERSONEL_ID INNER JOIN SORUN_KATEGORI_TABLOSU AS SOR ON S.KATEGORI_ID=SOR.KATEGORI_ID INNER JOIN ONAY_TABLOSU AS O ON O.ONAY_DURUM=S.ONAY_DURUM AND (S.ONAY_DURUM=0 OR S.ONAY_DURUM=1) AND P.PERSONEL_ID=" + personelID + "", conn); DataTable dt2 = new DataTable();
string mail = mailAl.ExecuteScalar().ToString(); dt2.Load(comm2.ExecuteReader()); string konu = "Bildiren Personel : " + dt2.Rows[0][0].ToString() + "\n" + " Personel Birimi : " + dt2.Rows[0][1].ToString() + "\n" + "Sorun Id : " + dt2.Rows[0][2].ToString() + "\n" + "Aklama : " + dt2.Rows[0][3].ToString() + "\n" + "Bildirim Zaman : " + dt2.Rows[0][4].ToString() + "\n" + "lem Balang Zaman : " + dt2.Rows[0][5].ToString() + "\n" + "Kategorisi : " + dt2.Rows[0][6].ToString() + "\n" + "Onay Durumu : " + dt2.Rows[0][7].ToString();
mailGonder(mail, "[email protected]", "sifre", konu, dt2.Rows[0][2].ToString() + ". Id Nolu Problem - " + dt2.Rows[0][1]);
} finally { conn.Close(); }
private void mailGonder(string kime, string kullaniciAdi, string sifre, string konu, string baslik)
SmtpClient sc = new SmtpClient(); sc.Host = "mail.gvg.com.tr"; sc.Port = 587; sc.Credentials = sad; sc.Send(mail); }
Zamanlayici.Start();
} }