protected void SendEmailToAbonent(string text, string phone) { try { AbonentModel theAbonent = new AbonentModel(); List <AbonentModel> theAbonentList = theAbonent.FindByPhone(phone); if (theAbonentList.Count == 0) { return; } theAbonent = theAbonentList[0]; if (theAbonent.Email.Length == 0) { return; } SmtpClient Smtp = new SmtpClient("10.198.1.200", 25); Smtp.EnableSsl = false; MailMessage message = new MailMessage(); message.From = new MailAddress("*****@*****.**"); message.To.Add(new MailAddress("*****@*****.**")); message.Subject = "SMSCENTER \\ Monit"; message.Body = text; Smtp.Send(message);//отправка } catch { } }
public void Update(AbonentModel theAbonent) { DBConnection Connection = new DBConnection(); try { Connection.Open(); OracleCommand cmd = new OracleCommand("PKG_WEB.PR_ABONENT_UPDATE", Connection.Connection); cmd.CommandType = System.Data.CommandType.StoredProcedure; OracleParameter id_abonent = new OracleParameter("id_abonent_", OracleType.Int32); OracleParameter name_abonent = new OracleParameter("name_abonent_", OracleType.VarChar); OracleParameter phone_abonent = new OracleParameter("phone_abonent_", OracleType.VarChar); OracleParameter description = new OracleParameter("description_", OracleType.VarChar); OracleParameter email = new OracleParameter("email_", OracleType.VarChar); OracleParameter id_branche = new OracleParameter("branch_id_", OracleType.Int32); OracleParameter id_updater = new OracleParameter("id_updater_", OracleType.Int32); id_abonent.Direction = ParameterDirection.Input; name_abonent.Direction = ParameterDirection.Input; phone_abonent.Direction = ParameterDirection.Input; description.Direction = ParameterDirection.Input; email.Direction = ParameterDirection.Input; id_branche.Direction = ParameterDirection.Input; id_updater.Direction = ParameterDirection.Input; id_abonent.Value = theAbonent.ID; name_abonent.Value = theAbonent.Name; phone_abonent.Value = theAbonent.Phone; description.Value = theAbonent.Description; email.Value = theAbonent.Email; id_branche.Value = theAbonent.BranchID; id_updater.Value = UserModel.CurrentUserId; cmd.Parameters.Add(id_abonent); cmd.Parameters.Add(name_abonent); cmd.Parameters.Add(phone_abonent); cmd.Parameters.Add(description); cmd.Parameters.Add(email); cmd.Parameters.Add(id_branche); cmd.Parameters.Add(id_updater); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { Connection.Close(); } }
public void Delete(AbonentModel theAbonent) { DBConnection Connection = new DBConnection(); try { Connection.Open(); OracleCommand cmd = new OracleCommand("PKG_WEB.PR_ABONENT_DELETE", Connection.Connection); cmd.CommandType = System.Data.CommandType.StoredProcedure; OracleParameter id_abonent = new OracleParameter("id_abonent_", OracleType.Int32); id_abonent.Direction = ParameterDirection.Input; id_abonent.Value = theAbonent.ID; cmd.Parameters.Add(id_abonent); cmd.ExecuteNonQuery(); } catch (Exception ex) { throw new Exception(ex.Message); } finally { Connection.Close(); } }
public List <AbonentModel> Abonents(Nullable <int> id_abon = null, string nm_abonent = null, string phn_abonent = null, Nullable <int> gr_abonent = null, Nullable <int> id_usr = null, string ord_by = null) { List <AbonentModel> Abonent = new List <AbonentModel>(); DBConnection conn = new DBConnection(); try { conn.Open(); OracleDataAdapter DataAdapter = new OracleDataAdapter(); OracleCommand cmd = new OracleCommand("PKG_WEB.PR_GET_ABONENTS", conn.Connection); cmd.CommandType = System.Data.CommandType.StoredProcedure; if (id_abon == null) { cmd.Parameters.AddWithValue("id_abonent_", OracleString.Null); } else { OracleParameter id_abonent = new OracleParameter("id_abonent_", OracleType.Int32); id_abonent.Direction = ParameterDirection.Input; id_abonent.Value = id_abon; cmd.Parameters.Add(id_abonent); } if (nm_abonent == null) { cmd.Parameters.AddWithValue("name_abonent_", OracleString.Null); } else { OracleParameter name_abonent = new OracleParameter("name_abonent_", OracleType.VarChar); name_abonent.Direction = ParameterDirection.Input; name_abonent.Value = nm_abonent; cmd.Parameters.Add(name_abonent); } if (phn_abonent == null) { cmd.Parameters.AddWithValue("phone_abonent_", OracleString.Null); } else { OracleParameter phone_abonent = new OracleParameter("phone_abonent_", OracleType.VarChar); phone_abonent.Direction = ParameterDirection.Input; phone_abonent.Value = phn_abonent; cmd.Parameters.Add(phone_abonent); } if (gr_abonent == null) { cmd.Parameters.AddWithValue("group_abonent_", OracleString.Null); } else { OracleParameter group_abonent = new OracleParameter("group_abonent_", OracleType.Int32); group_abonent.Direction = ParameterDirection.Input; group_abonent.Value = gr_abonent; cmd.Parameters.Add(group_abonent); } if (ord_by == null) { cmd.Parameters.AddWithValue("order_by_", OracleString.Null); } else { OracleParameter order_by = new OracleParameter("order_by_", OracleType.VarChar); order_by.Direction = ParameterDirection.Input; order_by.Value = ord_by; cmd.Parameters.Add(order_by); } if (id_usr == null) { cmd.Parameters.AddWithValue("id_user_", OracleString.Null); } else { OracleParameter id_user = new OracleParameter("id_user_", OracleType.Int32); id_user.Direction = ParameterDirection.Input; id_user.Value = id_usr; cmd.Parameters.Add(id_user); } Nullable <int> brnchs_user_id = UserModel.CurrentUserId; if (brnchs_user_id == null) { cmd.Parameters.AddWithValue("branches_user_id_", OracleString.Null); } else { OracleParameter branches_user_id = new OracleParameter("branches_user_id_", OracleType.Int32); branches_user_id.Direction = ParameterDirection.Input; branches_user_id.Value = brnchs_user_id; cmd.Parameters.Add(branches_user_id); } cmd.Parameters.Add("t_list", OracleType.Cursor).Direction = System.Data.ParameterDirection.Output; DataAdapter.SelectCommand = cmd; try { DataTable Table = new DataTable(); DataAdapter.Fill(Table); for (int i = 0; i < Table.Rows.Count; i++) { AbonentModel theAbonentModel = new AbonentModel(); theAbonentModel.ID = Convert.ToInt32(Table.Rows[i]["ID"].ToString()); theAbonentModel.Name = Table.Rows[i]["NAME"].ToString(); theAbonentModel.Phone = Table.Rows[i]["PHONE"].ToString(); theAbonentModel.Description = Table.Rows[i]["Description"].ToString(); theAbonentModel.Branche = Table.Rows[i]["BRANCHE_NAME"].ToString(); theAbonentModel.UserName = Table.Rows[i]["USER_NAME"].ToString(); theAbonentModel.BranchID = (Convert.ToInt32(Table.Rows[i]["BRANCHE_ID"].ToString())); theAbonentModel.Email = Table.Rows[i]["EMAIL"].ToString(); Abonent.Insert(i, theAbonentModel); } } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } } catch (Exception ex) { throw new Exception(ex.Message.ToString()); } finally { conn.Connection.Dispose(); conn.Connection.Close(); } return(Abonent); }