public void Insert(Punetori p) { SqlConnection con = Generals.GetNewConnection(); try { SqlCommand cmd = new SqlCommand("Punetoriinsert", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@Emri", (p.Emri)); cmd.Parameters.AddWithValue("@Mbiemri", (p.Mbiemri)); cmd.Parameters.AddWithValue("@Email", (p.Email)); cmd.Parameters.AddWithValue("@Gjinia", p.Gjinia); cmd.Parameters.AddWithValue("@adresa", p.Adresa); cmd.Parameters.AddWithValue("@Departamenti", p.Departamenti); cmd.Parameters.AddWithValue("@KrijuarNga", p.KrijuarNga); cmd.Parameters.AddWithValue("@IDLeternjoftimi", p.IDLeternjoftimi); cmd.Parameters.AddWithValue("@Datlindja", p.Datlindja); cmd.ExecuteNonQuery(); } finally { con.Close(); } }
public void SelectByID(int ID) { SqlConnection con = Generals.GetNewConnection(); try { SqlCommand cmd = new SqlCommand("PunetoriselectByID", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IDPunetori", ID); Punetori p = new Punetori(); SqlDataReader rdr = cmd.ExecuteReader(); while (rdr.Read()) { p.IDPunetori = (int)rdr["IDPunetori"]; p.Emri = ((string)rdr["Emri"]).ToString(); p.Mbiemri = ((string)rdr["Mbiemri"]).ToString(); p.Email = ((string)rdr["Email"]).ToString(); p.Gjinia = ((String)rdr["Gjinia"])[0]; if (rdr["KrijuarNga"] != DBNull.Value) { p.KrijuarNga = (int)rdr["KrijuarNga"]; } if (rdr["ModifikuarNga"] != DBNull.Value) { p.ModifikuarNga = (int)rdr["ModifikuarNga"]; } if (rdr["Departamenti"] != DBNull.Value) { p.Departamenti = (int)rdr["Departamenti"]; } p.IDLeternjoftimi = (long)rdr["IDLeternjoftimi"]; p.Datlindja = rdr["Datlindja"].ToString().Split(' ')[0]; p.Mosha = DateTime.Now.Year - Convert.ToInt32(p.Datlindja.Split('/')[0]); p.Adresa = (int)rdr["Adresa"]; } } finally { con.Close(); } }
public void update(Punetori p) { SqlConnection con = Generals.GetNewConnection(); try { SqlCommand cmd = new SqlCommand("Punetoriupdate", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@IDPunetori", p.IDPunetori); cmd.Parameters.AddWithValue("@Emri", (p.Emri)); cmd.Parameters.AddWithValue("@Mbiemri", (p.Mbiemri)); cmd.Parameters.AddWithValue("@Email", (p.Email)); cmd.Parameters.AddWithValue("@Gjinia", p.Gjinia); cmd.Parameters.AddWithValue("@Adresa", p.Adresa); cmd.Parameters.AddWithValue("@IDLeternjoftimi", p.IDLeternjoftimi); cmd.Parameters.AddWithValue("@ModifikuarNga", p.ModifikuarNga); cmd.ExecuteNonQuery(); } finally { con.Close(); } }