public static System.Collections.Generic.List <FirstAidBag_Service> GetBatteryListExpiredEmail(int CompanyID) { System.Collections.Generic.List <FirstAidBag_Service> result = new System.Collections.Generic.List <FirstAidBag_Service>(); int ID = -1; DBAccess db = new DBAccess(); db.AddInt("CompanyID", CompanyID); db.AddBoolean("IsAgent", AdgangsKontrol.IsAgent()); db.AddGuid("AgentID", CurrentUserID); SqlDataReader dr = default(SqlDataReader); try { dr = (System.Data.SqlClient.SqlDataReader)(db.ExecuteReader(_SQLSelectAllExpiredEmail)); if (dr.HasRows) { while (dr.Read()) { ID = System.Convert.ToInt32(dr.DBtoInt("ID")); result.Add(FirstAidBag_Service.GetService(ID)); } } dr.Close(); } catch (Exception ex) { throw (ex); } return(result); }
public static string Tags(string tekst, RescueTekniq.BOL.FirstAidBag_Service item) { string res = ""; StringBuilder sb = new StringBuilder(); sb.Append(tekst); sb.Replace("[VARE.TYPE]", "Service"); sb.Replace("[SERVICE.TYPE]", "[VARE.NAVN]"); sb.Replace("[DUEDATE]", item.ServiceDueDate.ToString("MMMM yyyy")); sb.Replace("[SERVICE.DUEDATE]", item.ServiceDueDate.ToString("MMMM yyyy")); sb.Replace("[SERVICE.BESØGSDATO]", item.ServiceDueDate.ToString("MMMM yyyy")); sb.Replace("[SERVICE.VISITEDDATE]", item.ServiceVisitedDate.ToString("dd MMMM yyyy")); sb.Replace("[SERVICE.BESØGTDATO]", item.ServiceVisitedDate.ToString("dd MMMM yyyy")); //.Replace("[SERVICE.EMAILSENDT]", item.ServiceEmailSendt.ToString()) sb.Replace("[SERVICE.GUID]", item.Guid.ToString()); sb.Replace("[SERVICE.VARENR]", "[VARE.VARENR]"); sb.Replace("[SERVICE.SALGSPRIS]", "[VARE.SALGSPRIS]"); sb.Replace("[SERVICE.RABAT]", "[VARE.RABAT]"); sb.Replace("[SERVICE.PRIS]", "[VARE.PRIS]"); sb.Replace("[SERVICE.KUNDEPRIS]", "[VARE.KUNDEPRIS]"); sb.Replace("[SERVICE.FRAGTGEBYR]", "[VARE.FRAGTGEBYR]"); sb.Replace("[SERVICE.FRAGTPRIS]", "[VARE.FRAGTPRIS]"); sb.Replace("[SERVICE.MOMS]", "[VARE.MOMS]"); sb.Replace("[SERVICE.TOTAL]", "[VARE.TOTAL]"); res = sb.ToString(); res = item.KundeGrpPris.Tags(res); res = item.FirstAidBag.Tags(res); return(res); }
public static int Insert(FirstAidBag_Service rec) { DBAccess db = new DBAccess(); AddParms(ref db, rec); SqlParameter objParam = new SqlParameter("@ID", 0); objParam.Direction = ParameterDirection.Output; db.Parameters.Add(objParam); int retval = db.ExecuteNonQuery(_SQLInsert); if (retval == 1) { rec.ID = int.Parse(objParam.Value.ToString()); AddLog(Status: "FirstAidBag_Service", Logtext: string.Format("Create FirstAidBag_Service: ID:{0}", rec.ID), Metode: "Insert"); return(rec.ID); } else { AddLog(Status: "FirstAidBag_Service", Logtext: string.Format("Failure to Create FirstAidBag_Service:"), logtype: LogTypeEnum.Error, Metode: "Insert"); return(-1); } }
public static List <FirstAidBag_Service> GetServicesByFAB(int FAB_FK) { List <FirstAidBag_Service> result = new List <FirstAidBag_Service>(); int ID = -1; DBAccess db = new DBAccess(); db.AddInt("FAB_FK", FAB_FK); db.AddBoolean("IsAgent", AdgangsKontrol.IsAgent()); db.AddGuid("AgentID", CurrentUserID); SqlDataReader dr = default(SqlDataReader); try { dr = (System.Data.SqlClient.SqlDataReader)(db.ExecuteReader(_SQLSelectByAED)); if (dr.HasRows) { while (dr.Read()) { ID = System.Convert.ToInt32(dr.DBtoInt("ID")); result.Add(FirstAidBag_Service.GetService(ID)); } } dr.Close(); } catch (Exception ex) { throw (ex); } return(result); }
public static int Delete(int ID) { FirstAidBag_Service S = new FirstAidBag_Service(); S.ID = ID; return(Delete(S)); }
public static int Delete(FirstAidBag_Service rec) { DBAccess db = new DBAccess(); db.AddInt("ID", rec.ID); int retval = db.ExecuteNonQuery(_SQLDelete); AddLog(Status: "FirstAidBag_Service", Logtext: string.Format("Delete FirstAidBag_Service: ID:{0}", rec.ID), Metode: "Delete"); return(retval); }
public static int Save(FirstAidBag_Service rec) { int retval = 0; if (rec.ID > 0) { retval = rec.Update(); } else { retval = rec.Insert(); } return(retval); }
protected static void Populate(SqlDataReader dr, FirstAidBag_Service c) { PopulateStandard(dr, c); var with_1 = c; with_1.Status = (RescueTekniq.BOL.FAB_ServiceStatusType)(dr.DBtoInt("Status")); with_1.FAB_FK = System.Convert.ToInt32(dr.DBtoInt("FAB_FK")); with_1.ServiceType = System.Convert.ToInt32(dr.DBtoInt("ServiceType")); with_1.ServiceActive = System.Convert.ToBoolean(dr.DBtoBoolean("ServiceActive")); with_1.ServiceDueDate = System.Convert.ToDateTime(dr.DBtoDate("ServiceDueDate")); with_1.ServiceVisitedDate = System.Convert.ToDateTime(dr.DBtoDate("ServiceVisitedDate")); with_1.ServiceConsultantID = System.Convert.ToInt32(dr.DBtoInt("ServiceConsultantID")); with_1.ServiceConsultant = dr.DBtoString("ServiceConsultant"); with_1.ServicePrice = System.Convert.ToDouble(dr.DBtoDouble("ServicePrice")); }
private static void AddParms(ref DBAccess db, FirstAidBag_Service c) { var with_1 = c; db.AddInt("Status", (System.Int32)with_1.Status); db.AddInt("FAB_FK", with_1.FAB_FK); db.AddInt("ServiceType", with_1.ServiceType); db.AddBoolean("ServiceActive", with_1.ServiceActive); db.AddDateTime("ServiceDueDate", with_1.ServiceDueDate); db.AddDateTime("ServiceVisitedDate", with_1.ServiceVisitedDate); db.AddInt("ServiceConsultantID", with_1.ServiceConsultantID); db.AddNVarChar("ServiceConsultant", with_1.ServiceConsultant, 50); db.AddMoney("ServicePrice", with_1.ServicePrice); // AddParmsStandard(db, c); }
public static List <FirstAidBag_Service> GetServicesByCriteria(string OrderBY, string criteria, params SqlParameter[] @params) { DBAccess db = new DBAccess(); //Dim conn As SqlConnection = DataFunctions.GetConnection() string query = ""; query += "SELECT "; if (OrderBY != "") { query += " TOP (100) PERCENT "; } query += " * FROM vw_Co2Db_FirstAidBag_Service "; query += " WHERE ( @IsAgent = 0 OR ( @IsAgent = 1 AND [AgentID] = @AgentID ) )"; if (criteria != "") { query += " AND (" + criteria + ")"; } if (OrderBY != "") { query += " ORDER BY " + OrderBY; } //Dim cmd As New SqlCommand(query, conn) db.CommandType = CommandType.Text; db.CommandText = query; db.AddRange(@params); db.AddBoolean("IsAgent", AdgangsKontrol.IsAgent()); db.AddGuid("AgentID", CurrentUserID); db.Open(); SqlDataReader dr = (SqlDataReader)(db.ExecuteReader()); //cmd.ExecuteReader() List <FirstAidBag_Service> list = new List <FirstAidBag_Service>(); while (dr.Read()) { FirstAidBag_Service service = new FirstAidBag_Service(); FirstAidBag_Service.Populate(dr, service); list.Add(service); } db.Dispose(); return(list); }
public static FirstAidBag_Service GetService(System.Guid Guid) { FirstAidBag_Service c = new FirstAidBag_Service(); DBAccess db = new DBAccess(); db.AddGuid("Guid", Guid); db.AddBoolean("IsAgent", AdgangsKontrol.IsAgent()); db.AddGuid("AgentID", CurrentUserID); SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectByGuid)); if (dr.HasRows) { while (dr.Read()) { Populate(dr, c); } } dr.Close(); return(c); }