public static string Tags(string tekst, RescueTekniq.BOL.FAB item) { string res = ""; StringBuilder sb = new StringBuilder(); sb.Append(tekst); sb.Replace("[VARE.TYPE]", "FAB/FirstAidBag"); sb.Replace("[FAB.ANSVARLIG]", item.ResponsibleName); sb.Replace("[FAB.ANSVARLIG.NAVN]", item.ResponsibleName); sb.Replace("[FAB.ANSVARLIG.EMAIL]", item.ResponsibleEmail); sb.Replace("[FAB.ANSVARLIG.TELEFON]", item.ResponsiblePhone); sb.Replace("[FAB.NOTE]", item.Note); sb.Replace("[FAB.PDF.LINK]", "<a href='[FAB.PDF]' target='_Blank'>LINK</a>"); sb.Replace("[FAB.PDF]", item.PDF); sb.Replace("[FAB.SERVICEDATE]", Combobox.GetTitleByValue("Combobox.Måneder", System.Convert.ToString(item.ServiceDate))); sb.Replace("[FAB.TYPE]", "[VARE.NAVN]"); sb.Replace("[FAB.SERIALNO]", item.SerialNo); sb.Replace("[FAB.LOCATION]", item.Location); sb.Replace("[FAB.LOCATIONFULDADR]", item.LocationFuldAdresse); sb.Replace("[FAB.VARENR]", "[VARE.VARENR]"); sb.Replace("[FAB.NAVN]", "[VARE.NAVN]"); sb.Replace("[FAB.MODEL]", "[VARE.NAVN]"); sb.Replace("[FAB.EXPIREDATE]", item.WarencyExpireDate.ToString("dd MMMM yyyy")); res = sb.ToString(); res = item.KundeGrpPris.Tags(res); res = item.Virksomhed.Tags(res); return(res); }
public static System.Collections.Generic.List <FAB> GetListSoonExpired(int CompanyID) { System.Collections.Generic.List <FAB> result = new System.Collections.Generic.List <FAB>(); int ID = -1; DBAccess db = new DBAccess(); db.AddInt("CompanyID", CompanyID); db.AddBoolean("IsAgent", AdgangsKontrol.IsAgent()); db.AddGuid("AgentID", CurrentUserID); System.Data.SqlClient.SqlDataReader dr = default(System.Data.SqlClient.SqlDataReader); //Try dr = (System.Data.SqlClient.SqlDataReader)(db.ExecuteReader(_SQLSelectAllSoonExpired)); if (dr.HasRows) { while (dr.Read()) { ID = System.Convert.ToInt32(dr.DBtoInt("ID")); result.Add(FAB.GetFAB(ID)); } } dr.Close(); //Catch ex As Exception // Throw ex //End Try return(result); }
/// <summary> /// Creates the PDF document. /// </summary> public Document CreateDocument() { if (!_FAB.loaded) { if (_fabID > 0) { _FAB = new RescueTekniq.BOL.FAB(_fabID); } } if (!_FAB.loaded) { throw (new Exception("Førstehjælpstaske findes ikke, ID ukendt :" + fabID.ToString())); } // Create a new MigraDoc document this.document = new Document(); var with_1 = this.document.Info; with_1.Title = "Førstehjælpstaske regstering nr. " + System.Convert.ToString(_fabID); with_1.Subject = "Førstehjælpstaske registering"; with_1.Author = Company.name; with_1.Comment = ""; with_1.Keywords = ""; DefineStyles(); CreatePage(); FillContent(); return(this.document); }
public static int MoveToNewOwner(int ID, int NewOwner) { FAB rec = new FAB(ID); rec.CompanyID = NewOwner; AddLog(Status: "FAB", Logtext: string.Format("Update FAB: ID:{0} SNo:{1} New owner: {2}-{3}", rec.ID, rec.SerialNo, rec.CompanyID, rec.Firmanavn), Metode: "MoveToNewOwner"); return(rec.Save()); }
public static int Update(FAB c) { DBAccess db = new DBAccess(); db.AddInt("ID", c.ID); AddParms(ref db, c); int retval = db.ExecuteNonQuery(_SQLUpdate); AddLog(Status: "FAB", Logtext: string.Format("Update FAB: ID:{0} SNo:{1} ", c.ID, c.SerialNo), Metode: "Update"); return(retval); }
public static int Save(FAB rec) { int retval = 0; //db.ExecuteNonQuery(_SQLUpdate) if (rec.ID > 0) { retval = rec.Update(); } else { retval = rec.Insert(); } return(retval); }
public static List <FAB> GetFABsByCriteria(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 "; 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 <FAB> list = new List <FAB>(); while (dr.Read()) { FAB _fab = new FAB(); FAB.Populate(dr, _fab); list.Add(_fab); } db.Dispose(); return(list); }
public static int Delete(FAB rec) { int retval = -1; if (rec.ID > 0) { foreach (FirstAidBag_Service S in rec.ServiceList) { S.Delete(); } DBAccess db = new DBAccess(); db.AddInt("ID", rec.ID); retval = db.ExecuteNonQuery(_SQLDelete); AddLog(Status: "FAB", Logtext: string.Format("Delete FAB: ID:{0} SNo:{1} ", rec.ID, rec.SerialNo), Metode: "Delete"); } return(retval); }
private static void AddParms(ref DBAccess db, FAB c) { var with_1 = c; db.AddInt("Status", (System.Int32)with_1.Status); db.AddInt("CompanyID", with_1.CompanyID); db.AddInt("ModelID", with_1.ModelID); db.AddNVarChar("SerialNo", with_1.SerialNo, 50); db.AddDateTime("DeleveryDate", with_1.DeleveryDate); db.AddDateTime("WarencyExpireDate", with_1.WarencyExpireDate); db.AddDateTime("DecommissionDate", with_1.DecommissionDate); db.AddDateTime("EmailSendt", with_1.EmailSendt); db.AddInt("BilagStatus", (System.Int32)with_1.BilagStatus); db.AddDateTime("BilagSendtDato", with_1.BilagSendtDato); db.AddDateTime("BilagModtagetDato", with_1.BilagModtagetDato); db.AddNVarChar("ResponsibleName", with_1.ResponsibleName, 50); db.AddNVarChar("ResponsiblePhone", with_1.ResponsiblePhone, 16); db.AddNVarChar("ResponsibleEmail", with_1.ResponsibleEmail, 250); db.AddNVarChar("LocationAdresse", with_1.LocationAdresse, 50); db.AddNVarChar("LocationPostnr", with_1.LocationPostnr, 16); db.AddNVarChar("LocationBy", with_1.LocationBy, 50); db.AddNVarChar("LocationState", with_1.LocationState, 50); db.AddInt("LocationLandID", with_1.LocationLandID); db.AddNVarChar("Location", with_1.Location, -1); db.AddNVarChar("LocationBuildingNo", with_1.LocationBuildingNo, 10); db.AddInt("ServiceDate", with_1.ServiceDate); db.AddDateTime("ServiceDateEmail", with_1.ServiceDateEmail); db.AddBoolean("VisibleRescueinfo", with_1.VisibleRescueinfo); // db.AddNVarChar("RegisterretAF", with_1.RegisterretAF, 50); db.AddNVarChar("Note", with_1.Note, -1); AddParmsStandard(db, c); }
private static void Populate(System.Data.SqlClient.SqlDataReader dr, FAB c) { var with_1 = c; with_1.Status = (RescueTekniq.BOL.FAB_StatusEnum)(dr.DBtoInt("Status")); with_1.CompanyID = System.Convert.ToInt32(dr.DBtoInt("CompanyID")); with_1.ModelID = System.Convert.ToInt32(dr.DBtoInt("ModelID")); with_1.SerialNo = dr.DBtoString("SerialNo"); with_1.DeleveryDate = System.Convert.ToDateTime(dr.DBtoDate("DeleveryDate")); with_1.WarencyExpireDate = System.Convert.ToDateTime(dr.DBtoDate("WarencyExpireDate")); with_1.DecommissionDate = System.Convert.ToDateTime(dr.DBtoDate("DecommissionDate")); with_1.EmailSendt = System.Convert.ToDateTime(dr.DBtoDate("EmailSendt")); with_1.BilagStatus = (RescueTekniq.BOL.FAB_BilagStatus)(dr.DBtoInt("BilagStatus")); with_1.BilagSendtDato = System.Convert.ToDateTime(dr.DBtoDate("BilagSendtDato")); with_1.BilagModtagetDato = System.Convert.ToDateTime(dr.DBtoDate("BilagModtagetDato")); with_1.ResponsibleName = dr.DBtoString("ResponsibleName"); with_1.ResponsiblePhone = dr.DBtoString("ResponsiblePhone"); with_1.ResponsibleEmail = dr.DBtoString("ResponsibleEmail"); with_1.LocationAdresse = dr.DBtoString("LocationAdresse"); with_1.LocationPostnr = dr.DBtoString("LocationPostnr"); with_1.LocationBy = dr.DBtoString("LocationBy"); with_1.LocationState = dr.DBtoString("LocationState"); with_1.LocationLandID = System.Convert.ToInt32(dr.DBtoInt("LocationLandID")); with_1.Location = dr.DBtoString("Location"); with_1.LocationBuildingNo = dr.DBtoString("LocationBuildingNo"); with_1.ServiceDate = System.Convert.ToInt32(dr.DBtoInt("ServiceDate")); with_1.ServiceDateEmail = System.Convert.ToDateTime(dr.DBtoDate("ServiceDateEmail")); with_1.VisibleRescueinfo = System.Convert.ToBoolean(dr.DBtoBoolean("VisibleRescueinfo")); with_1.RegisterretAF = dr.DBtoString("RegisterretAF"); with_1.Note = dr.DBtoString("Note"); PopulateStandard(dr, c); }
public static FAB GetFABBySerialNo(string SerialNo) { DBAccess db = new DBAccess(); FAB c = new FAB(); db.AddNVarChar("SerialNo", SerialNo, 50); db.AddBoolean("IsAgent", AdgangsKontrol.IsAgent()); db.AddGuid("AgentID", CurrentUserID); SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectBySerialNo)); if (dr.HasRows) { while (dr.Read()) { Populate(dr, c); } } dr.Close(); return(c); }
public static FAB GetFABbyGuid(Guid GuID) { DBAccess db = new DBAccess(); FAB c = new FAB(); 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); }
public static int Insert(FAB 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 = Funktioner.ToInt(objParam.Value, -1); //Integer.Parse(objParam.Value.ToString) AddLog(Status: "FAB", Logtext: string.Format("Create FAB: ID:{0} SNo:{1} ", rec.ID, rec.SerialNo), Metode: "Insert"); return(rec.ID); } else { AddLog(Status: "FAB", Logtext: string.Format("Failure to Create FAB: SNo:{0}", rec.SerialNo), logtype: LogTypeEnum.Error, Metode: "Insert"); return(-1); } }
public static int Delete(int ID) { FAB item = new FAB(ID); return(Delete(item)); }