Esempio n. 1
0
        public static int Insert(Pax rec)
        {
            DBAccess db = new DBAccess();

            AddParms(ref db, rec);
            //db.addGetInteger("ID")

            SqlParameter objParam = new SqlParameter("@ID", 0);

            objParam.Direction = ParameterDirection.Output;
            db.Parameters.Add(objParam);

            int retval = db.ExecuteNonQuery(_SQLInsert);

            if (retval == 1)
            {
                rec.ID = Convert.ToInt32(objParam.Value);
                AddLog(Status: "Pax", Logtext: string.Format("Create Pax: ID:{0}", rec.ID), Metode: "Insert");
                return(rec.ID);
            }
            else
            {
                AddLog(Status: "Pax", Logtext: string.Format("Failure to Create Pax:"), logtype: LogTypeEnum.Error, Metode: "Insert");
                return(-1);
            }
        }
Esempio n. 2
0
        public static string Tags(string tekst, RescueTekniq.BOL.Pax item)
        {
            string        res = "";
            StringBuilder sb  = new StringBuilder();

            //UPDATE [vicjos1_RescueTekniq].[vicjos1_sysadm].[Co2Db_Pax]
            //   SET [CompanyID] = <CompanyID, int,>
            //      ,[Status] = <Status, int,>
            //      ,[ModelID] = <ModelID, int,>
            //      ,[SerialNo] = <SerialNo, nvarchar(50),>
            //      ,[InvoiceID] = <InvoiceID, int,>
            //      ,[SalesDate] = <SalesDate, datetime,>

            // WHERE <Search Conditions,,>
            //GO

            sb.Append(tekst);
            //.Replace("[VARE.TYPE]", "Pax")
            //.Replace("[Pax.TYPE]", "[VARE.NAVN]")

            sb.Replace("[Pax.SalesDate]", item.SalesDate.ToString("dd. MMM yyyy"));
            sb.Replace("[Pax.Sales.DATE]", item.SalesDate.ToString("dd. MMM yyyy"));

            sb.Replace("[Pax.InvoiceID]", System.Convert.ToString(item.InvoiceID));
            sb.Replace("[Pax.ModelID]", System.Convert.ToString(item.ModelID));
            sb.Replace("[Pax.SerialNo]", item.SerialNo);

            sb.Replace("[Pax.GUID]", item.Guid.ToString());

            res = sb.ToString();

            return(res);
        }
Esempio n. 3
0
        public static System.Collections.Generic.List <Pax> GetPaxList()
        {
            System.Collections.Generic.List <Pax> result = new System.Collections.Generic.List <Pax>();
            int      ID = -1;
            DBAccess db = new DBAccess();

            db.AddBoolean("IsAgent", AdgangsKontrol.IsAgent());
            db.AddGuid("AgentID", CurrentUserID);

            SqlDataReader dr = default(SqlDataReader);

            try
            {
                dr = (System.Data.SqlClient.SqlDataReader)(db.ExecuteReader(_SQLSelectAll));
                if (dr.HasRows)
                {
                    while (dr.Read())
                    {
                        Pax pc = new Pax();
                        Populate(dr, pc);
                        result.Add(pc);
                    }
                }
                dr.Close();
            }
            catch (Exception ex)
            {
                throw (ex);
            }

            return(result);
        }
Esempio n. 4
0
        public static int Update(Pax rec)
        {
            DBAccess db = new DBAccess();

            db.AddInt("ID", rec.ID);
            AddParms(ref db, rec);

            int retval = db.ExecuteNonQuery(_SQLUpdate);

            AddLog(Status: "Pax", Logtext: string.Format("Update Pax: ID:{0}", rec.ID), Metode: "Update");
            return(retval);
        }
Esempio n. 5
0
        //UPDATE [vicjos1_RescueTekniq].[vicjos1_sysadm].[Co2Db_Pax]
        //   SET [CompanyID] = <CompanyID, int,>
        //      ,[Status] = <Status, int,>
        //      ,[ModelID] = <ModelID, int,>
        //      ,[SerialNo] = <SerialNo, nvarchar(50),>
        //      ,[InvoiceID] = <InvoiceID, int,>
        //      ,[SalesDate] = <SalesDate, datetime,>

        //      ,[OprettetAf] = <OprettetAf, nvarchar(50),>
        //      ,[OprettetDen] = <OprettetDen, datetime,>
        //      ,[OprettetIP] = <OprettetIP, nvarchar(15),>
        //      ,[RettetAf] = <RettetAf, nvarchar(50),>
        //      ,[RettetDen] = <RettetDen, datetime,>
        //      ,[RettetIP] = <RettetIP, nvarchar(50),>
        // WHERE <Search Conditions,,>
        //GO

        private static void AddParms(ref DBAccess db, Pax 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.AddInt("InvoiceID", with_1.InvoiceID);
            db.AddNVarChar("SerialNo", with_1.SerialNo, 50);
            db.AddDateTime("SalesDate", with_1.SalesDate);
            AddParmsStandard(db, c);
        }
Esempio n. 6
0
        public static int Save(Pax rec)
        {
            int retval = 0;

            if (rec.ID > 0)
            {
                retval = rec.Update();
            }
            else
            {
                retval = rec.Insert();
            }
            return(retval);
        }
Esempio n. 7
0
        protected static void Populate(SqlDataReader dr, Pax c)
        {
            PopulateStandard(dr, c);
            var with_1 = c;

            with_1.Status = (RescueTekniq.BOL.PaxStatusType)(dr.DBtoInt("Status"));

            with_1.Status    = (RescueTekniq.BOL.PaxStatusType)(dr.DBtoInt("Status"));
            with_1.CompanyID = System.Convert.ToInt32(dr.DBtoInt("CompanyID"));
            with_1.ModelID   = System.Convert.ToInt32(dr.DBtoInt("ModelID"));
            with_1.InvoiceID = System.Convert.ToInt32(dr.DBtoInt("InvoiceID"));
            with_1.SerialNo  = dr.DBtoString("SerialNo");
            with_1.SalesDate = System.Convert.ToDateTime(dr.DBtoDate("SalesDate"));
        }
Esempio n. 8
0
        public static List <Pax> GetPaxsByCriteria(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_Pax ";
            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());

            List <Pax> list = new List <Pax>();

            while (dr.Read())
            {
                Pax pc = new Pax();
                Pax.Populate(dr, pc);
                list.Add(pc);
            }

            db.Dispose();

            return(list);
        }
Esempio n. 9
0
        public static Pax GetPax(int ID)
        {
            Pax      c  = new Pax();
            DBAccess db = new DBAccess();

            db.AddInt("ID", ID);

            SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectID));

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Populate(dr, c);
                }
            }
            dr.Close();
            return(c);
        }
Esempio n. 10
0
        public static Pax GetPaxByCompanyID(int CompanyID)
        {
            DBAccess db = new DBAccess();
            Pax      pc = new Pax();

            db.AddInt("CompanyID", CompanyID);
            db.AddBoolean("IsAgent", AdgangsKontrol.IsAgent());
            db.AddGuid("AgentID", CurrentUserID);

            SqlDataReader dr = (SqlDataReader)(db.ExecuteReader(_SQLSelectCompanyID));

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Populate(dr, pc);
                }
            }
            if (!dr.IsClosed)
            {
                dr.Close();
            }
            return(pc);
        }
Esempio n. 11
0
 public static int Delete(Pax rec)
 {
     return(Delete(rec.ID));
 }