예제 #1
0
        public static int Insert(Invoiceline c)
        {
            DBAccess db = new DBAccess();

            if (c.Status <= (int)Invoiceline_StatusEnum.Create)
            {
                c.Status = Invoiceline_StatusEnum.Active;
            }
            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)
            {
                int res = -1;
                res = Funktioner.ToInteger(objParam.Value);
                AddLog(Status: "Invoiceline", Logtext: string.Format("Create Invoiceline: ID:{0}", c.ID), Metode: "Insert");
                return(res);
            }
            else
            {
                AddLog(Status: "Invoiceline", Logtext: string.Format("Failure to Invoiceline AED_Battery:"), logtype: LogTypeEnum.Error, Metode: "Insert");
                return(-1);
            }
        }
        public static int Insert(KursusDeltager c)
        {
            DBAccess db = new DBAccess();

            if (c.Status == KursusKursistStatusEnum.Initialize)
            {
                c.Status = KursusKursistStatusEnum.Aktiv;
            }
            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.ToInteger(objParam.Value.ToString(), -1);
                return(c.ID);
            }
            else
            {
                return(-1);
            }
        }
        public static int Insert(PurchaseOrderItem rec)
        {
            DBAccess db = new DBAccess();

            if (rec.Status <= (int)PurchaseOrderItem_StatusEnum.Create)
            {
                rec.Status = PurchaseOrderItem_StatusEnum.Active;
            }
            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)
            {
                int res = -1;
                res = Funktioner.ToInteger(objParam.Value);
                AddLog(Status: "PurchaseOrderItem", Logtext: string.Format("Create PurchaseOrderItem: ID:{0}", rec.ID), Metode: "Insert");
                return(res);
            }
            else
            {
                AddLog(Status: "PurchaseOrderItem", Logtext: string.Format("Failure to create PurchaseOrderItem:"), logtype: LogTypeEnum.Error, Metode: "Insert");
                return(-1);
            }
        }
        public static int GetSupplierID(int PurchaseOrderID)
        {
            DBAccess db = new DBAccess();

            db.AddInt("PurchaseOrderID", PurchaseOrderID);
            int res = 0;

            try
            {
                object obj = db.ExecuteScalar(_SQLGetSupplierID);
                res = Funktioner.ToInteger(obj);
            }
            catch
            {
                res = 0;
            }
            return(res);
        }