Ejemplo n.º 1
0
        public static tilbudHeader GetTilbudByCompany(int CompanyID)
        {
            DBAccess     db = new DBAccess();
            tilbudHeader c  = new tilbudHeader();

            db.AddInt("CompanyID", CompanyID);

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

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

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Populate(dr, c);
                }
                dr.Close();
                return(c);
            }
            else
            {
                dr.Close();
                return(c); //Nothing
            }
        }
Ejemplo n.º 2
0
        public static object UpdateStatus(int id, TilbudStatusEnum status)
        {
            tilbudHeader t = new tilbudHeader(id);

            t.Status = status;
            return(Update(t));
        }
Ejemplo n.º 3
0
        public static int Update(tilbudHeader c)
        {
            DBAccess db = new DBAccess();

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

            int retval = db.ExecuteNonQuery(_SQLUpdate);

            AddLog(Status: "tilbudHeader", Logtext: string.Format("Update tilbudHeader: ID:{0} KontaktPerson:{1} ", c.ID, c.KontaktPerson), Metode: "Update");
            return(retval);
        }
Ejemplo n.º 4
0
 private static void AddParms(ref DBAccess db, tilbudHeader c)
 {
     db.AddInt("Status", (System.Int32)c.Status);
     db.AddInt("CompanyID", c.CompanyID);
     db.AddDateTime("Opretdato", c.Opretdato);
     db.AddDateTime("Udlobdato", c.Udlobdato);
     db.AddInt("AnsvarligID", c.AnsvarligID);
     db.AddGuid("AnsvarligGUID", c.AnsvarligGUID);
     db.AddNVarChar("KontaktEmail", c.KontaktEmail, 250);
     db.AddNVarChar("KontaktPerson", c.KontaktPerson, 50);
     db.AddNVarChar("Noter", c.Noter, -1);
     db.AddNVarChar("TilbudsTillaeg", c.TilbudsTillaeg, -1);
     db.AddDecimal("Transport", c.Transport);
     AddParmsStandard(db, c);
 }
Ejemplo n.º 5
0
        public static int Insert(int CompanyID, int AnsvarligID, Guid AnsvarligGUID, string KontaktEmail, string KontaktPerson, string Noter, string TilbudsTillaeg, DateTime OpretDato, DateTime UdlobDato, TilbudStatusEnum Status)
        {
            tilbudHeader c = new tilbudHeader();

            c.CompanyID      = CompanyID;
            c.AnsvarligID    = AnsvarligID;
            c.AnsvarligGUID  = AnsvarligGUID;
            c.KontaktEmail   = KontaktEmail;
            c.KontaktPerson  = KontaktPerson;
            c.Noter          = Noter;
            c.TilbudsTillaeg = TilbudsTillaeg;
            c.Opretdato      = OpretDato;
            c.Udlobdato      = UdlobDato;
            c.Status         = Status;
            return(Insert(c));
        }
Ejemplo n.º 6
0
        private static void Populate(SqlDataReader dr, tilbudHeader c)
        {
            PopulateStandard(dr, c);
            var with_1 = c;

            with_1.Status         = (RescueTekniq.BOL.TilbudStatusEnum)(dr.DBtoInt("Status"));
            with_1.CompanyID      = System.Convert.ToInt32(dr.DBtoInt("CompanyID"));
            with_1.Opretdato      = System.Convert.ToDateTime(dr.DBtoDate("Opretdato"));
            with_1.Udlobdato      = System.Convert.ToDateTime(dr.DBtoDate("Udlobdato"));
            with_1.AnsvarligID    = System.Convert.ToInt32(dr.DBtoInt("AnsvarligID"));
            with_1.AnsvarligGUID  = dr.DBtoGuid("AnsvarligGUID");
            with_1.KontaktEmail   = dr.DBtoString("KontaktEmail");
            with_1.KontaktPerson  = dr.DBtoString("KontaktPerson");
            with_1.Noter          = dr.DBtoString("Noter");
            with_1.TilbudsTillaeg = dr.DBtoString("TilbudsTillaeg");
            with_1.Transport      = System.Convert.ToDecimal(dr.DBtoDecimal("Transport"));
        }
Ejemplo n.º 7
0
        public static int Delete(tilbudHeader c)
        {
            int retval = -1;

            if (c.loaded)
            {
                foreach (TilbudsLinie item in c.Tilbudslinier)
                {
                    item.Delete();
                }

                DBAccess db = new DBAccess();
                db.AddInt("ID", c.ID);
                retval = db.ExecuteNonQuery(_SQLDelete);
                AddLog(Status: "tilbudHeader", Logtext: string.Format("Delete tilbudHeader: ID:{0}", c.ID), Metode: "Delete");
            }
            return(retval);
        }
Ejemplo n.º 8
0
        public static int Insert(tilbudHeader c)
        {
            DBAccess db = new DBAccess();

            AddParms(ref db, c);

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

            objParam.Direction = ParameterDirection.Output;
            db.Parameters.Add(objParam);
            int retval = db.ExecuteNonQuery(_SQLInsert);

            if (retval == 1)
            {
                c.ID = Funktioner.ToInt(objParam.Value);
                AddLog(Status: "tilbudHeader", Logtext: string.Format("Create tilbudHeader: ID:{0} KontaktPerson:{1} ", c.ID, c.KontaktPerson), Metode: "Insert");
                return(c.ID); //Integer.Parse(objParam.Value.ToString)
            }
            else
            {
                AddLog(Status: "tilbudHeader", Logtext: string.Format("Failure to Create tilbudHeader: KontaktPerson:{0}", c.KontaktPerson), logtype: LogTypeEnum.Error, Metode: "Insert");
                return(-1);
            }
        }
Ejemplo n.º 9
0
        public static int Delete(int ID)
        {
            tilbudHeader item = new tilbudHeader(ID);

            return(item.Delete());
        }
Ejemplo n.º 10
0
 public static int Purge(tilbudHeader c)
 {
     return(Purge(c.ID));
 }